开源软件名称(OpenSource Name):increments/qiita-markdown开源软件地址(OpenSource Url):https://github.com/increments/qiita-markdown开源编程语言(OpenSource Language):Ruby 100.0%开源软件介绍(OpenSource Introduction):Qiita::MarkdownQiita-specified markdown processor.
Basic UsageQiita::Markdown::Processor provides markdown rendering logic. processor = Qiita::Markdown::Processor.new(hostname: "example.com")
processor.call(markdown)
# => {
# codes: [
# {
# code: "1 + 1\n",
# language: "ruby",
# filename: "example.rb",
# },
# ],
# mentioned_usernames: [
# "alice",
# "bob",
# ],
# output: "<h1>Example</h1>\n...",
# } FiltersQiita::Markdown is built on jch/html-pipeline. Add your favorite html-pipeline-compatible filters. processor = Qiita::Markdown::Processor.new(hostname: "example.com")
processor.filters << HTML::Pipeline::ImageMaxWidthFilter
processor.call(text) Context
processor = Qiita::Markdown::Processor.new(asset_root: "http://example.com/assets", hostname: "example.com")
processor.call(text) Rendering SummaryThere's another processor Qiita::Markdown::SummaryProcessor, which is for rendering a summary of markdown document. It simplifies a document by removing complex markups and also truncates it to a specific length without breaking the document structure. Note that this processor does not produce the ContextSummaryProcessor accepts the following context in addition to the Processor's context: {
truncate: {
length: 100, # Documents will be truncated if it exceeds this character count. (Integer)
omission: '…' # A string added to the end of document when it's truncated. (String, nil)
}
} processor = Qiita::Markdown::SummaryProcessor.new(truncate: { length: 80 }, hostname: "example.com")
processor.call(text) |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论