在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:MichaelHatherly/CommonMark.jl开源软件地址:https://github.com/MichaelHatherly/CommonMark.jl开源编程语言:Julia 100.0%开源软件介绍:CommonMarkA CommonMark-compliant parser for Julia. Interfaceusing CommonMark Create a markdown parser with the default CommonMark settings and then add footnote syntax to our parser. parser = Parser()
enable!(parser, FootnoteRule()) Parse some text to an abstract syntax tree from a ast = parser("Hello *world*") Parse the contents of a source file: ast = open(parser, "document.md") Write body = html(ast)
content = "<head></head><body>$body</body>" Write to a file. open("file.tex", "w") do file
latex(file, ast)
println(file, "rest of document...")
end Or write to a buffer, such as term(stdout, ast) Output FormatsSupported output formats are currently:
ExtensionsExtensions can be enabled using the TypographyConvert ASCII dashes, ellipses, and quotes to their Unicode equivalents. enable!(parser, TypographyRule()) Keyword arguments available for
which all default to Admonitionsenable!(parser, AdmonitionRule()) Front matterFenced blocks at the start of a file containing structured data.
The block must start on the first line of the file. Supported blocks are:
To enable provide the using JSON
enable!(parser, FrontMatterRule(json=JSON.Parser.parse)) You can access front matter from a parsed file using ast = open(parser, "document.md")
meta = frontmatter(ast) Footnotesenable!(parser, FootnoteRule()) MathJulia-style inline and display maths: Some ``\LaTeX`` math:
```math
f(a) = \frac{1}{2\pi}\int_{0}^{2\pi} (\alpha+R\cos(\theta))d\theta
``` Enabled with: enable!(parser, MathRule()) Dollar-style inline and display math is also available using enable!(parser, DollarMathRule()) Supported syntax:
For more complex math, such as multiline display math, use the literal block
syntax available with TablesPipe-style tables, similar to GitHub's tables. Literal | Column One | Column Two | Column Three |
|:---------- | ---------- |:------------:|
| Row `1` | Column `2` | |
| *Row* 2 | **Row** 2 | Column ``|`` | Rows with more cells than specified have the trailing cells discarded, and rows with less cells are topped up with empty cells. Enabled with: enable!(parser, TableRule()) Raw ContentOverload literal syntax to support passing through any type of raw content. enable!(parser, RawContentRule()) By default This is raw HTML: `<img src="myimage.jpg">`{=html}.
And here's an HTML block:
```{=html}
<div id="main">
<div class="article">
``` ```{=latex}
\begin{tikzpicture}
\draw[gray, thick] (-1,2) -- (2,-4);
\draw[gray, thick] (-1,-1) -- (2,2);
\filldraw[black] (0,0) circle (2pt) node[anchor=west] {Intersection point};
\end{tikzpicture}
``` This can be used to pass through different complex content that can't be easily handled by CommonMark natively without any loss of expressiveness. Custom raw content handlers can also be passed through when enabling the rule.
The naming scheme is enable!(p, RawContentRule(rst_inline=RstInline)) The last example would require the definition of a custom AttributesBlock and inline nodes can be tagged with arbitrary metadata in the form of
key/value pairs using the enable!(p, AttributeRule()) Block attributes appear directly above the node that they target: {#my_id color="red"}
# Heading This will attach the metadata Inline attributes appear directly after the node that they target: *Some styled text*{background="green"}. Which will attach metadata CSS-style shorthand syntax
CitationsUse the following to enable in-text citations and reference list generation: enable!(p, CitationRule()) Syntax for citations is similar to what is offered by
Pandoc. Citations start with Citations can either appear in square brackets [@id], or they can be written as
part of the text like @id. Bracketed citations can contain more than one
citation; separated by semi-colons [@one; @two; and @three].
{#refs}
# References A reference section that will be populated with a list of all references can be
marked using a Citations and reference lists are formatted following the Chicago Manual of Style. Styling will, in future versions, be customisable using Citation Style Language styles. The reference data used for citations must be provided in a format matching
CSL JSON.
Pass this data to html(ast, Dict{String,Any}("references" => JSON.parsefile("references.json"))) CSL JSON can be exported easily from reference management software such as
Zotero or generated via Note that the text format of the reference list is not important, and does not
have to be JSON data. So long as the shape of the data matches CSL JSON it
is valid. Below we use YAML ---
references:
- id: abelson1996
author:
- family: Abelson
given: Harold
- family: Sussman
given: Gerald Jay
edition: 2nd Editon
event-place: Cambridge
ISBN: 0-262-01153-0
issued:
date-parts:
- - 1996
publisher: MIT Press/McGraw-Hill
publisher-place: Cambridge
title: Structure and interpretation of computer programs
type: book
---
Here's a citation [@abelson1996].
{#refs}
# References Auto IdentifiersHeadings within a document can be assigned enable!(p, AutoIdentifierRule()) Identifiers are determined with CommonMark DefaultsBlock rules enabled by default in
Inline rules enabled by default in
These can all be disabled using Note Until version Writer ConfigurationWhen writing to an output format configuration data can be provided by:
Front matter takes precedence over the passed Notable VariablesValues used to determine template behaviour:
Generic variables that can be included in templates to customise documents:
Format-specific variables that should be used only in a particular format's template. They are namespaced to avoid collision with other variables.
The following are automatically available in document templates.
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论