README.md

  1goldmark
  2==========================================
  3
  4[![https://pkg.go.dev/github.com/yuin/goldmark](https://pkg.go.dev/badge/github.com/yuin/goldmark.svg)](https://pkg.go.dev/github.com/yuin/goldmark)
  5[![https://github.com/yuin/goldmark/actions?query=workflow:test](https://github.com/yuin/goldmark/workflows/test/badge.svg?branch=master&event=push)](https://github.com/yuin/goldmark/actions?query=workflow:test)
  6[![https://coveralls.io/github/yuin/goldmark](https://coveralls.io/repos/github/yuin/goldmark/badge.svg?branch=master)](https://coveralls.io/github/yuin/goldmark)
  7[![https://goreportcard.com/report/github.com/yuin/goldmark](https://goreportcard.com/badge/github.com/yuin/goldmark)](https://goreportcard.com/report/github.com/yuin/goldmark)
  8
  9> A Markdown parser written in Go. Easy to extend, standards-compliant, well-structured.
 10
 11goldmark is compliant with CommonMark 0.31.2.
 12
 13- [goldmark playground](https://yuin.github.io/goldmark/playground/) : Try goldmark online. This playground is built with WASM(5-10MB).
 14
 15Motivation
 16----------------------
 17I needed a Markdown parser for Go that satisfies the following requirements:
 18
 19- Easy to extend.
 20    - Markdown is poor in document expressions compared to other light markup languages such as reStructuredText.
 21    - We have extensions to the Markdown syntax, e.g. PHP Markdown Extra, GitHub Flavored Markdown.
 22- Standards-compliant.
 23    - Markdown has many dialects.
 24    - GitHub-Flavored Markdown is widely used and is based upon CommonMark, effectively mooting the question of whether or not CommonMark is an ideal specification.
 25        - CommonMark is complicated and hard to implement.
 26- Well-structured.
 27    - AST-based; preserves source position of nodes.
 28- Written in pure Go.
 29
 30[golang-commonmark](https://gitlab.com/golang-commonmark/markdown) may be a good choice, but it seems to be a copy of [markdown-it](https://github.com/markdown-it).
 31
 32[blackfriday.v2](https://github.com/russross/blackfriday/tree/v2) is a fast and widely-used implementation, but is not CommonMark-compliant and cannot be extended from outside of the package, since its AST uses structs instead of interfaces.
 33
 34Furthermore, its behavior differs from other implementations in some cases, especially regarding lists: [Deep nested lists don't output correctly #329](https://github.com/russross/blackfriday/issues/329), [List block cannot have a second line #244](https://github.com/russross/blackfriday/issues/244), etc.
 35
 36This behavior sometimes causes problems. If you migrate your Markdown text from GitHub to blackfriday-based wikis, many lists will immediately be broken.
 37
 38As mentioned above, CommonMark is complicated and hard to implement, so Markdown parsers based on CommonMark are few and far between.
 39
 40Features
 41----------------------
 42
 43- **Standards-compliant.**  goldmark is fully compliant with the latest [CommonMark](https://commonmark.org/) specification.
 44- **Extensible.**  Do you want to add a `@username` mention syntax to Markdown?
 45  You can easily do so in goldmark. You can add your AST nodes,
 46  parsers for block-level elements, parsers for inline-level elements,
 47  transformers for paragraphs, transformers for the whole AST structure, and
 48  renderers.
 49- **Performance.**  goldmark's performance is on par with that of cmark,
 50  the CommonMark reference implementation written in C.
 51- **Robust.**  goldmark is tested with `go test --fuzz`.
 52- **Built-in extensions.**  goldmark ships with common extensions like tables, strikethrough,
 53  task lists, and definition lists.
 54- **Depends only on standard libraries.**
 55
 56Installation
 57----------------------
 58```bash
 59$ go get github.com/yuin/goldmark
 60```
 61
 62
 63Usage
 64----------------------
 65Import packages:
 66
 67```go
 68import (
 69    "bytes"
 70    "github.com/yuin/goldmark"
 71)
 72```
 73
 74
 75Convert Markdown documents with the CommonMark-compliant mode:
 76
 77```go
 78var buf bytes.Buffer
 79if err := goldmark.Convert(source, &buf); err != nil {
 80  panic(err)
 81}
 82```
 83
 84With options
 85------------------------------
 86
 87```go
 88var buf bytes.Buffer
 89if err := goldmark.Convert(source, &buf, parser.WithContext(ctx)); err != nil {
 90  panic(err)
 91}
 92```
 93
 94| Functional option | Type | Description |
 95| ----------------- | ---- | ----------- |
 96| `parser.WithContext` | A `parser.Context` | Context for the parsing phase. |
 97
 98Context options
 99----------------------
100
101| Functional option | Type | Description |
102| ----------------- | ---- | ----------- |
103| `parser.WithIDs` | A `parser.IDs` | `IDs` allows you to change logics that are related to element id(ex: Auto heading id generation). |
104
105
106Custom parser and renderer
107--------------------------
108```go
109import (
110    "bytes"
111    "github.com/yuin/goldmark"
112    "github.com/yuin/goldmark/extension"
113    "github.com/yuin/goldmark/parser"
114    "github.com/yuin/goldmark/renderer/html"
115)
116
117md := goldmark.New(
118          goldmark.WithExtensions(extension.GFM),
119          goldmark.WithParserOptions(
120              parser.WithAutoHeadingID(),
121          ),
122          goldmark.WithRendererOptions(
123              html.WithHardWraps(),
124              html.WithXHTML(),
125          ),
126      )
127var buf bytes.Buffer
128if err := md.Convert(source, &buf); err != nil {
129    panic(err)
130}
131```
132
133| Functional option | Type | Description |
134| ----------------- | ---- | ----------- |
135| `goldmark.WithParser` | `parser.Parser`  | This option must be passed before `goldmark.WithParserOptions` and `goldmark.WithExtensions` |
136| `goldmark.WithRenderer` | `renderer.Renderer`  | This option must be passed before `goldmark.WithRendererOptions` and `goldmark.WithExtensions`  |
137| `goldmark.WithParserOptions` | `...parser.Option`  |  |
138| `goldmark.WithRendererOptions` | `...renderer.Option` |  |
139| `goldmark.WithExtensions` | `...goldmark.Extender`  |  |
140
141Parser and Renderer options
142------------------------------
143
144### Parser options
145
146| Functional option | Type | Description |
147| ----------------- | ---- | ----------- |
148| `parser.WithBlockParsers` | A `util.PrioritizedSlice` whose elements are `parser.BlockParser` | Parsers for parsing block level elements. |
149| `parser.WithInlineParsers` | A `util.PrioritizedSlice` whose elements are `parser.InlineParser` | Parsers for parsing inline level elements. |
150| `parser.WithParagraphTransformers` | A `util.PrioritizedSlice` whose elements are `parser.ParagraphTransformer` | Transformers for transforming paragraph nodes. |
151| `parser.WithASTTransformers` | A `util.PrioritizedSlice` whose elements are `parser.ASTTransformer` | Transformers for transforming an AST. |
152| `parser.WithAutoHeadingID` | `-` | Enables auto heading ids. |
153| `parser.WithAttribute` | `-` | Enables custom attributes. Currently only headings supports attributes. |
154
155### HTML Renderer options
156
157| Functional option | Type | Description |
158| ----------------- | ---- | ----------- |
159| `html.WithWriter` | `html.Writer` | `html.Writer` for writing contents to an `io.Writer`. |
160| `html.WithHardWraps` | `-` | Render newlines as `<br>`.|
161| `html.WithXHTML` | `-` | Render as XHTML. |
162| `html.WithUnsafe` | `-` | By default, goldmark does not render raw HTML or potentially dangerous links. With this option, goldmark renders such content as written. |
163
164### Built-in extensions
165
166- `extension.Table`
167    - [GitHub Flavored Markdown: Tables](https://github.github.com/gfm/#tables-extension-)
168- `extension.Strikethrough`
169    - [GitHub Flavored Markdown: Strikethrough](https://github.github.com/gfm/#strikethrough-extension-)
170- `extension.Linkify`
171    - [GitHub Flavored Markdown: Autolinks](https://github.github.com/gfm/#autolinks-extension-)
172- `extension.TaskList`
173    - [GitHub Flavored Markdown: Task list items](https://github.github.com/gfm/#task-list-items-extension-)
174- `extension.GFM`
175    - This extension enables Table, Strikethrough, Linkify and TaskList.
176    - This extension does not filter tags defined in [6.11: Disallowed Raw HTML (extension)](https://github.github.com/gfm/#disallowed-raw-html-extension-).
177    If you need to filter HTML tags, see [Security](#security).
178    - If you need to parse github emojis, you can use [goldmark-emoji](https://github.com/yuin/goldmark-emoji) extension.
179- `extension.DefinitionList`
180    - [PHP Markdown Extra: Definition lists](https://michelf.ca/projects/php-markdown/extra/#def-list)
181- `extension.Footnote`
182    - [PHP Markdown Extra: Footnotes](https://michelf.ca/projects/php-markdown/extra/#footnotes)
183- `extension.Typographer`
184    - This extension substitutes punctuations with typographic entities like [smartypants](https://daringfireball.net/projects/smartypants/).
185- `extension.CJK`
186    - This extension is a shortcut for CJK related functionalities.
187
188### Attributes
189The `parser.WithAttribute` option allows you to define attributes on some elements.
190
191Currently only headings support attributes.
192
193**Attributes are being discussed in the
194[CommonMark forum](https://talk.commonmark.org/t/consistent-attribute-syntax/272).
195This syntax may possibly change in the future.**
196
197
198#### Headings
199
200```
201## heading ## {#id .className attrName=attrValue class="class1 class2"}
202
203## heading {#id .className attrName=attrValue class="class1 class2"}
204```
205
206```
207heading {#id .className attrName=attrValue}
208============
209```
210
211### Table extension
212The Table extension implements [Table(extension)](https://github.github.com/gfm/#tables-extension-), as
213defined in [GitHub Flavored Markdown Spec](https://github.github.com/gfm/).
214
215Specs are defined for XHTML, so specs use some deprecated attributes for HTML5.
216
217You can override alignment rendering method via options.
218
219| Functional option | Type | Description |
220| ----------------- | ---- | ----------- |
221| `extension.WithTableCellAlignMethod` | `extension.TableCellAlignMethod` | Option indicates how are table cells aligned. |
222
223### Typographer extension
224
225The Typographer extension translates plain ASCII punctuation characters into typographic-punctuation HTML entities.
226
227Default substitutions are:
228
229| Punctuation | Default entity |
230| ------------ | ---------- |
231| `'`           | `&lsquo;`, `&rsquo;` |
232| `"`           | `&ldquo;`, `&rdquo;` |
233| `--`       | `&ndash;` |
234| `---`      | `&mdash;` |
235| `...`      | `&hellip;` |
236| `<<`       | `&laquo;` |
237| `>>`       | `&raquo;` |
238
239You can override the default substitutions via `extensions.WithTypographicSubstitutions`:
240
241```go
242markdown := goldmark.New(
243    goldmark.WithExtensions(
244        extension.NewTypographer(
245            extension.WithTypographicSubstitutions(extension.TypographicSubstitutions{
246                extension.LeftSingleQuote:  []byte("&sbquo;"),
247                extension.RightSingleQuote: nil, // nil disables a substitution
248            }),
249        ),
250    ),
251)
252```
253
254### Linkify extension
255
256The Linkify extension implements [Autolinks(extension)](https://github.github.com/gfm/#autolinks-extension-), as
257defined in [GitHub Flavored Markdown Spec](https://github.github.com/gfm/).
258
259Since the spec does not define details about URLs, there are numerous ambiguous cases.
260
261You can override autolinking patterns via options.
262
263| Functional option | Type | Description |
264| ----------------- | ---- | ----------- |
265| `extension.WithLinkifyAllowedProtocols` | `[][]byte \| []string` | List of allowed protocols such as `[]string{ "http:" }` |
266| `extension.WithLinkifyURLRegexp` | `*regexp.Regexp` | Regexp that defines URLs, including protocols |
267| `extension.WithLinkifyWWWRegexp` | `*regexp.Regexp` | Regexp that defines URL starting with `www.`. This pattern corresponds to [the extended www autolink](https://github.github.com/gfm/#extended-www-autolink) |
268| `extension.WithLinkifyEmailRegexp` | `*regexp.Regexp` | Regexp that defines email addresses` |
269
270Example, using [xurls](https://github.com/mvdan/xurls):
271
272```go
273import "mvdan.cc/xurls/v2"
274
275markdown := goldmark.New(
276    goldmark.WithRendererOptions(
277        html.WithXHTML(),
278        html.WithUnsafe(),
279    ),
280    goldmark.WithExtensions(
281        extension.NewLinkify(
282            extension.WithLinkifyAllowedProtocols([]string{
283                "http:",
284                "https:",
285            }),
286            extension.WithLinkifyURLRegexp(
287                xurls.Strict(),
288            ),
289        ),
290    ),
291)
292```
293
294### Footnotes extension
295
296The Footnote extension implements [PHP Markdown Extra: Footnotes](https://michelf.ca/projects/php-markdown/extra/#footnotes).
297
298This extension has some options:
299
300| Functional option | Type | Description |
301| ----------------- | ---- | ----------- |
302| `extension.WithFootnoteIDPrefix` | `[]byte \| string` |  a prefix for the id attributes.|
303| `extension.WithFootnoteIDPrefixFunction` | `func(gast.Node) []byte` |  a function that determines the id attribute for given Node.|
304| `extension.WithFootnoteLinkTitle` | `[]byte \| string` |  an optional title attribute for footnote links.|
305| `extension.WithFootnoteBacklinkTitle` | `[]byte \| string` |  an optional title attribute for footnote backlinks. |
306| `extension.WithFootnoteLinkClass` | `[]byte \| string` |  a class for footnote links. This defaults to `footnote-ref`. |
307| `extension.WithFootnoteBacklinkClass` | `[]byte \| string` |  a class for footnote backlinks. This defaults to `footnote-backref`. |
308| `extension.WithFootnoteBacklinkHTML` | `[]byte \| string` |  a class for footnote backlinks. This defaults to `&#x21a9;&#xfe0e;`. |
309
310Some options can have special substitutions. Occurrences of “^^” in the string will be replaced by the corresponding footnote number in the HTML output. Occurrences of “%%” will be replaced by a number for the reference (footnotes can have multiple references).
311
312`extension.WithFootnoteIDPrefix` and `extension.WithFootnoteIDPrefixFunction` are useful if you have multiple Markdown documents displayed inside one HTML document to avoid footnote ids to clash each other.
313
314`extension.WithFootnoteIDPrefix` sets fixed id prefix, so you may write codes like the following:
315
316```go
317for _, path := range files {
318    source := readAll(path)
319    prefix := getPrefix(path)
320
321    markdown := goldmark.New(
322        goldmark.WithExtensions(
323            NewFootnote(
324                WithFootnoteIDPrefix(path),
325            ),
326        ),
327    )
328    var b bytes.Buffer
329    err := markdown.Convert(source, &b)
330    if err != nil {
331        t.Error(err.Error())
332    }
333}
334```
335
336`extension.WithFootnoteIDPrefixFunction` determines an id prefix by calling given function, so you may write codes like the following:
337
338```go
339markdown := goldmark.New(
340    goldmark.WithExtensions(
341        NewFootnote(
342                WithFootnoteIDPrefixFunction(func(n gast.Node) []byte {
343                    v, ok := n.OwnerDocument().Meta()["footnote-prefix"]
344                    if ok {
345                        return util.StringToReadOnlyBytes(v.(string))
346                    }
347                    return nil
348                }),
349        ),
350    ),
351)
352
353for _, path := range files {
354    source := readAll(path)
355    var b bytes.Buffer
356
357    doc := markdown.Parser().Parse(text.NewReader(source))
358    doc.Meta()["footnote-prefix"] = getPrefix(path)
359    err := markdown.Renderer().Render(&b, source, doc)
360}
361```
362
363You can use [goldmark-meta](https://github.com/yuin/goldmark-meta) to define a id prefix in the markdown document:
364
365
366```markdown
367---
368title: document title
369slug: article1
370footnote-prefix: article1
371---
372
373# My article
374
375```
376
377### CJK extension
378CommonMark gives compatibilities a high priority and original markdown was designed by westerners. So CommonMark lacks considerations for languages like CJK.
379
380This extension provides additional options for CJK users.
381
382| Functional option | Type | Description |
383| ----------------- | ---- | ----------- |
384| `extension.WithEastAsianLineBreaks` | `...extension.EastAsianLineBreaksStyle` | Soft line breaks are rendered as a newline. Some asian users will see it as an unnecessary space. With this option, soft line breaks between east asian wide characters will be ignored. This defaults to `EastAsianLineBreaksStyleSimple`. |
385| `extension.WithEscapedSpace` | `-` | Without spaces around an emphasis started with east asian punctuations, it is not interpreted as an emphasis(as defined in CommonMark spec). With this option, you can avoid this inconvenient behavior by putting 'not rendered' spaces around an emphasis like `太郎は\ **「こんにちわ」**\ といった`. |
386
387#### Styles of Line Breaking
388
389| Style | Description |
390| ----- | ----------- |
391| `EastAsianLineBreaksStyleSimple` | Soft line breaks are ignored if both sides of the break are east asian wide character. This behavior is the same as [`east_asian_line_breaks`](https://pandoc.org/MANUAL.html#extension-east_asian_line_breaks) in Pandoc. |
392| `EastAsianLineBreaksCSS3Draft` | This option implements CSS text level3 [Segment Break Transformation Rules](https://drafts.csswg.org/css-text-3/#line-break-transform) with [some enhancements](https://github.com/w3c/csswg-drafts/issues/5086). |
393
394#### Example of `EastAsianLineBreaksStyleSimple`
395
396Input Markdown:
397
398```md
399私はプログラマーです。
400東京の会社に勤めています。
401GoでWebアプリケーションを開発しています。
402```
403
404Output:
405
406```html
407<p>私はプログラマーです。東京の会社に勤めています。\nGoでWebアプリケーションを開発しています。</p>
408```
409
410#### Example of `EastAsianLineBreaksCSS3Draft`
411
412Input Markdown:
413
414```md
415私はプログラマーです。
416東京の会社に勤めています。
417GoでWebアプリケーションを開発しています。
418```
419
420Output:
421
422```html
423<p>私はプログラマーです。東京の会社に勤めています。GoでWebアプリケーションを開発しています。</p>
424```
425
426Security
427--------------------
428By default, goldmark does not render raw HTML or potentially-dangerous URLs.
429If you need to gain more control over untrusted contents, it is recommended that you
430use an HTML sanitizer such as [bluemonday](https://github.com/microcosm-cc/bluemonday).
431
432Benchmark
433--------------------
434You can run this benchmark in the `_benchmark` directory.
435
436### against other golang libraries
437
438blackfriday v2 seems to be the fastest, but as it is not CommonMark compliant, its performance cannot be directly compared to that of the CommonMark-compliant libraries.
439
440goldmark, meanwhile, builds a clean, extensible AST structure, achieves full compliance with
441CommonMark, and consumes less memory, all while being reasonably fast.
442
443- MBP 2019 13″(i5, 16GB), Go1.17
444
445```
446BenchmarkMarkdown/Blackfriday-v2-8                   302           3743747 ns/op         3290445 B/op      20050 allocs/op
447BenchmarkMarkdown/GoldMark-8                         280           4200974 ns/op         2559738 B/op      13435 allocs/op
448BenchmarkMarkdown/CommonMark-8                       226           5283686 ns/op         2702490 B/op      20792 allocs/op
449BenchmarkMarkdown/Lute-8                              12          92652857 ns/op        10602649 B/op      40555 allocs/op
450BenchmarkMarkdown/GoMarkdown-8                        13          81380167 ns/op         2245002 B/op      22889 allocs/op
451```
452
453### against cmark (CommonMark reference implementation written in C)
454
455- MBP 2019 13″(i5, 16GB), Go1.17
456
457```
458----------- cmark -----------
459file: _data.md
460iteration: 50
461average: 0.0044073057 sec
462------- goldmark -------
463file: _data.md
464iteration: 50
465average: 0.0041611990 sec
466```
467
468As you can see, goldmark's performance is on par with cmark's.
469
470Extensions
471--------------------
472### List of extensions
473
474- [goldmark-meta](https://github.com/yuin/goldmark-meta): A YAML metadata
475  extension for the goldmark Markdown parser.
476- [goldmark-highlighting](https://github.com/yuin/goldmark-highlighting): A syntax-highlighting extension
477  for the goldmark markdown parser.
478- [goldmark-emoji](https://github.com/yuin/goldmark-emoji): An emoji
479  extension for the goldmark Markdown parser.
480- [goldmark-mathjax](https://github.com/litao91/goldmark-mathjax): Mathjax support for the goldmark markdown parser
481- [goldmark-pdf](https://github.com/stephenafamo/goldmark-pdf): A PDF renderer that can be passed to `goldmark.WithRenderer()`.
482- [goldmark-hashtag](https://github.com/abhinav/goldmark-hashtag): Adds support for `#hashtag`-based tagging to goldmark.
483- [goldmark-wikilink](https://github.com/abhinav/goldmark-wikilink): Adds support for `[[wiki]]`-style links to goldmark.
484- [goldmark-anchor](https://github.com/abhinav/goldmark-anchor): Adds anchors (permalinks) next to all headers in a document.
485- [goldmark-figure](https://github.com/mangoumbrella/goldmark-figure): Adds support for rendering paragraphs starting with an image to `<figure>` elements.
486- [goldmark-frontmatter](https://github.com/abhinav/goldmark-frontmatter): Adds support for YAML, TOML, and custom front matter to documents.
487- [goldmark-toc](https://github.com/abhinav/goldmark-toc): Adds support for generating tables-of-contents for goldmark documents.
488- [goldmark-mermaid](https://github.com/abhinav/goldmark-mermaid): Adds support for rendering [Mermaid](https://mermaid-js.github.io/mermaid/) diagrams in goldmark documents.
489- [goldmark-pikchr](https://github.com/jchenry/goldmark-pikchr): Adds support for rendering [Pikchr](https://pikchr.org/home/doc/trunk/homepage.md) diagrams in goldmark documents.
490- [goldmark-embed](https://github.com/13rac1/goldmark-embed): Adds support for rendering embeds from YouTube links.
491- [goldmark-latex](https://github.com/soypat/goldmark-latex): A $\LaTeX$ renderer that can be passed to `goldmark.WithRenderer()`.
492- [goldmark-fences](https://github.com/stefanfritsch/goldmark-fences): Support for pandoc-style [fenced divs](https://pandoc.org/MANUAL.html#divs-and-spans) in goldmark.
493- [goldmark-d2](https://github.com/FurqanSoftware/goldmark-d2): Adds support for [D2](https://d2lang.com/) diagrams.
494- [goldmark-katex](https://github.com/FurqanSoftware/goldmark-katex): Adds support for [KaTeX](https://katex.org/) math and equations.
495- [goldmark-img64](https://github.com/tenkoh/goldmark-img64): Adds support for embedding images into the document as DataURL (base64 encoded).
496- [goldmark-enclave](https://github.com/quail-ink/goldmark-enclave): Adds support for embedding youtube/bilibili video, X's [oembed tweet](https://publish.twitter.com/), [tradingview](https://www.tradingview.com/widget/)'s chart, [quail](https://quail.ink)'s widget into the document.
497- [goldmark-wiki-table](https://github.com/movsb/goldmark-wiki-table): Adds support for embedding Wiki Tables.
498- [goldmark-tgmd](https://github.com/Mad-Pixels/goldmark-tgmd): A Telegram markdown renderer that can be passed to `goldmark.WithRenderer()`.
499
500### Loading extensions at runtime
501[goldmark-dynamic](https://github.com/yuin/goldmark-dynamic) allows you to write a goldmark extension in Lua and load it at runtime without re-compilation.
502
503Please refer to  [goldmark-dynamic](https://github.com/yuin/goldmark-dynamic) for details.
504
505
506goldmark internal(for extension developers)
507----------------------------------------------
508### Overview
509goldmark's Markdown processing is outlined in the diagram below.
510
511```
512            <Markdown in []byte, parser.Context>
513                           |
514                           V
515            +-------- parser.Parser ---------------------------
516            | 1. Parse block elements into AST
517            |   1. If a parsed block is a paragraph, apply 
518            |      ast.ParagraphTransformer
519            | 2. Traverse AST and parse blocks.
520            |   1. Process delimiters(emphasis) at the end of
521            |      block parsing
522            | 3. Apply parser.ASTTransformers to AST
523                           |
524                           V
525                      <ast.Node>
526                           |
527                           V
528            +------- renderer.Renderer ------------------------
529            | 1. Traverse AST and apply renderer.NodeRenderer
530            |    corespond to the node type
531
532                           |
533                           V
534                        <Output>
535```
536
537### Parsing
538Markdown documents are read through `text.Reader` interface.
539
540AST nodes do not have concrete text. AST nodes have segment information of the documents, represented by `text.Segment` .
541
542`text.Segment` has 3 attributes: `Start`, `End`, `Padding` .
543
544(TBC)
545
546**TODO**
547
548See `extension` directory for examples of extensions.
549
550Summary:
551
5521. Define AST Node as a struct in which `ast.BaseBlock` or `ast.BaseInline` is embedded.
5532. Write a parser that implements `parser.BlockParser` or `parser.InlineParser`.
5543. Write a renderer that implements `renderer.NodeRenderer`.
5554. Define your goldmark extension that implements `goldmark.Extender`.
556
557
558Donation
559--------------------
560BTC: 1NEDSyUmo4SMTDP83JJQSWi1MvQUGGNMZB
561
562License
563--------------------
564MIT
565
566Author
567--------------------
568Yusuke Inuzuka