Class: ReDiscount
- Inherits:
-
Object
- Object
- ReDiscount
- Defined in:
- lib/mdutils/rediscount.rb
Constant Summary collapse
- VERSION =
'3.1.0'
Instance Attribute Summary collapse
-
#autolink ⇒ Object
自动链接.
-
#explicitlist ⇒ Object
显式列表.
-
#filter_html ⇒ Object
过滤 HTML 标签.
-
#filter_styles ⇒ Object
过滤样式标签.
-
#footnotes ⇒ Object
启用脚注.
-
#generate_toc ⇒ Object
生成目录.
-
#latex ⇒ Object
LaTeX 支持.
-
#md1compat ⇒ Object
Markdown 1.0 兼容.
-
#no_image ⇒ Object
禁用图片.
-
#no_links ⇒ Object
禁用链接.
-
#no_pseudo_protocols ⇒ Object
禁用伪协议.
-
#no_strikethrough ⇒ Object
禁用删除线.
-
#no_superscript ⇒ Object
禁用上标.
-
#no_tables ⇒ Object
禁用表格.
-
#safelink ⇒ Object
安全链接.
-
#smart ⇒ Object
解析标志访问器.
-
#strict ⇒ Object
严格模式.
-
#text ⇒ String
readonly
Markdown 原始文本.
Instance Method Summary collapse
-
#initialize(text, *flags) ⇒ ReDiscount
constructor
初始化 Markdown 解析器。.
-
#to_html ⇒ String
将 Markdown 文本转换为 HTML。.
-
#toc_content ⇒ String
生成目录 HTML 内容。.
Constructor Details
#initialize(text, *flags) ⇒ ReDiscount
初始化 Markdown 解析器。
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/mdutils/rediscount.rb', line 82 def initialize(text, *flags) @text = text.to_s @smart = false @filter_html = false @filter_styles = false @footnotes = false @generate_toc = false @no_image = false @no_links = false @no_tables = false @strict = false @autolink = false @safelink = false @no_pseudo_protocols = false @no_superscript = false @no_strikethrough = false @latex = false @explicitlist = false @md1compat = false flags.each do |flag| send("#{flag}=", true) if respond_to?("#{flag}=") end end |
Instance Attribute Details
#autolink ⇒ Object
自动链接
64 65 66 |
# File 'lib/mdutils/rediscount.rb', line 64 def autolink @autolink end |
#explicitlist ⇒ Object
显式列表
70 71 72 |
# File 'lib/mdutils/rediscount.rb', line 70 def explicitlist @explicitlist end |
#filter_html ⇒ Object
过滤 HTML 标签
56 57 58 |
# File 'lib/mdutils/rediscount.rb', line 56 def filter_html @filter_html end |
#filter_styles ⇒ Object
过滤样式标签
57 58 59 |
# File 'lib/mdutils/rediscount.rb', line 57 def filter_styles @filter_styles end |
#footnotes ⇒ Object
启用脚注
58 59 60 |
# File 'lib/mdutils/rediscount.rb', line 58 def footnotes @footnotes end |
#generate_toc ⇒ Object
生成目录
59 60 61 |
# File 'lib/mdutils/rediscount.rb', line 59 def generate_toc @generate_toc end |
#latex ⇒ Object
LaTeX 支持
69 70 71 |
# File 'lib/mdutils/rediscount.rb', line 69 def latex @latex end |
#md1compat ⇒ Object
Markdown 1.0 兼容
71 72 73 |
# File 'lib/mdutils/rediscount.rb', line 71 def md1compat @md1compat end |
#no_image ⇒ Object
禁用图片
60 61 62 |
# File 'lib/mdutils/rediscount.rb', line 60 def no_image @no_image end |
#no_links ⇒ Object
禁用链接
61 62 63 |
# File 'lib/mdutils/rediscount.rb', line 61 def no_links @no_links end |
#no_pseudo_protocols ⇒ Object
禁用伪协议
66 67 68 |
# File 'lib/mdutils/rediscount.rb', line 66 def no_pseudo_protocols @no_pseudo_protocols end |
#no_strikethrough ⇒ Object
禁用删除线
68 69 70 |
# File 'lib/mdutils/rediscount.rb', line 68 def no_strikethrough @no_strikethrough end |
#no_superscript ⇒ Object
禁用上标
67 68 69 |
# File 'lib/mdutils/rediscount.rb', line 67 def no_superscript @no_superscript end |
#no_tables ⇒ Object
禁用表格
62 63 64 |
# File 'lib/mdutils/rediscount.rb', line 62 def no_tables @no_tables end |
#safelink ⇒ Object
安全链接
65 66 67 |
# File 'lib/mdutils/rediscount.rb', line 65 def safelink @safelink end |
#smart ⇒ Object
解析标志访问器
55 56 57 |
# File 'lib/mdutils/rediscount.rb', line 55 def smart @smart end |
#strict ⇒ Object
严格模式
63 64 65 |
# File 'lib/mdutils/rediscount.rb', line 63 def strict @strict end |
#text ⇒ String (readonly)
Returns Markdown 原始文本.
52 53 54 |
# File 'lib/mdutils/rediscount.rb', line 52 def text @text end |
Instance Method Details
#to_html ⇒ String
将 Markdown 文本转换为 HTML。
110 111 112 113 |
# File 'lib/mdutils/rediscount.rb', line 110 def to_html parser = MarkdownParser.new(@text, self) parser.to_html end |
#toc_content ⇒ String
生成目录 HTML 内容。
需要 :generate_toc 标志启用,且文档中包含标题。
120 121 122 123 |
# File 'lib/mdutils/rediscount.rb', line 120 def toc_content parser = MarkdownParser.new(@text, self) parser.toc_content end |