Commit Graph

51 Commits

Author SHA1 Message Date
RichΛrd 32e5a5055f
feat: add language tag to codeblocks (#3) 2021-04-05 08:17:40 -04:00
Roman Volosovskyi fdf2b95957
strong-emph, better del 2020-10-19 13:06:09 +03:00
Andrea Maria Piana e3ba6c6109
add mentions 2019-12-09 11:58:22 +01:00
Andrea Maria Piana af599402d0
Stripped down version of markdown 2019-11-13 12:43:44 +01:00
Miek Gieben 4ef28e6c7e Add non-blocking-space
A backslash-space is a non-blocking-space that is recognized when
enabling the NonBlockingSpace extension.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-08-17 10:53:44 -07:00
Krzysztof Kowalczyk 545fcbe0ef undo EmptyLinesBreakList parser flag 2019-02-02 03:26:55 -08:00
Krzysztof Kowalczyk cea22d0ff9 ast.Print with more information 2019-02-01 19:14:26 -08:00
Miek Gieben a07fde8256 links: keep deferred status
Keep track if a link or footnote was deferred. This makes it possible to
do this again when generating (formatted) markdown output. I.e. now all
deferred links/footnotes become inline because it does not know that
some of them had been deferred.

Without this patch:

    Footnote^[footnote *with* stuff ]

With this patch:

    Footnote[^id]

    [^id]: footnote *with* stuff

Where the later is how to the original markdown file was formatted.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-11-03 18:53:29 +00:00
Miek Gieben 7e9a76ee31 mmark: allow citation suffix
mmark 2 promised to implement this: allow a citation suffix:
[@!RFC1034, p. 144]. Implement this by splitting on the comma.
Add multiple tests for this new behavior.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-10-25 21:34:10 +01:00
Miek Gieben b9745ffc72 caption: allow heading ID
A user pinged me that is was apparently possible w/ mmark1 and it has
some kind of elegance to bring it back to mmark2.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-10-20 13:13:43 +01:00
Miek Gieben 95f2dead98 Allow hooking into footnote generation
This adds an (empty) *ast.Footnote before the footnotes are added.
This can be used to customize the it, i.e. putting it in a new section.
The HR output is put behind a flag html.FootnoteNoHRTag to suppress that
as well.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-26 12:30:20 +01:00
Miek Gieben 65e2c79c3b Add super and subscript support
Other markdown parser put this behind an extension; do the same here:
extension: SuperSubscript.

Detect sequences between ^ and ~ as super and subscript respectively.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-24 14:35:20 +02:00
Miek Gieben f5d29afaf9 Update readme and other fixes
Update the README with table footer syntax: fixes #77
Update the README and just point to mmark.nl instead of listing
all mmark syntax elements (again).
Fix multiple classes in headers.
Make header.Special a bool and rename it it IsSpecial.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-18 13:05:53 +02:00
Miek Gieben a98b0dbeb9 Table: parse table footers
This takes the syntax from kramdown: https://kramdown.gettalong.org/syntax.html#tables
Rename tableHead to tableHeader, and use tableFooter for consistency.

It's not guarded by any parser extension, except parser.Tables

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-18 11:33:30 +02:00
Miek Gieben 26c06b95cd index: use idx-N for the ID
Make the ID generation more specific to the index.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-16 17:45:43 +02:00
Miek Gieben 744eed10c1 just make it an int
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-15 16:48:04 +02:00
Miek Gieben a4a196b482 Add uniq ID to indices
To allow linking to indices by giving them an ID; without it an index
can not refer back to the actual index item from main index at the end
of the document.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-15 16:32:06 +02:00
Miek Gieben 699609b6d8 parser: allow indices
This parsed (!item) as an index, subitems are allowed as well as making
the index primary (by adding another !: (!!item). The HTML output is
non-existent and there is no go in gomarkdown to render an index (left
to a custom renderer)

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-13 19:21:00 +02:00
Miek Gieben 45707013cb Add callout parsing
Add ast.Callout node that is detected in test and extra utils to parse
it in codeblock.

See https://mmark.nl/post/syntax/#callouts for what they are.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-10 22:03:41 +01:00
Miek Gieben 543ba837f9 Make a String() function for AlignmentFlags
Implement the TODO and a method `String()` that returns a string for
AlignmentFlags.

Pondered doing the same for Matters and CitationTypes, but those are
more renderer dependent (and not standard).

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-07 07:43:02 +01:00
Krzysztof Kowalczyk 7462de8d99 tweak comment 2018-08-05 11:37:51 -07:00
Krzysztof Kowalczyk de14329a8f remove unused function 2018-08-05 11:34:53 -07:00
Miek Gieben 864377cdbf More citations
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-03 14:27:02 +01:00
Miek Gieben 67d6503d9a add citations
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-03 09:23:22 +01:00
Miek Gieben fca7a9e0a6 Mmark: add cross reference syntax
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-03 08:19:08 +01:00
Miek Gieben bf6ad50793 more
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-03 08:18:27 +01:00
Miek Gieben 2daaee88a2 new node definition
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-01 19:22:52 +01:00
Miek Gieben 77587eb931 Support captions
This adds Mmark support for captions under quotes block or fenced code
blocks. This can be used by adding: `Caption: <text>` under the block.
All text up to the next empty line is read.

This adds ast.Caption, which is a noop in the html/renderer because the
elements need to walk this node outside of the main ast. The node can
only hold span elements (p.inline()).

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-01 19:21:35 +01:00
Miek Gieben 4a5b716e6a more caption work
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-01 19:19:12 +01:00
Miek Gieben 055b0aac3f Add document divisions
Signed-off-by: Miek Gieben <miek@miek.nl>

Implement document divisions

front/main/back-matter. There is no html equivalent of these.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-01 13:46:33 +00:00
Miek Gieben f1700b7c88 WIP: Mmark: implement asides
This implements asides, blockquote like paragraph prexifed with `A>`
instead of just a '>'

Adds the extension MmarkAsides

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-30 22:23:27 +01:00
Miek Gieben f45815586d Mmark: add SpecialHeading
This adds detection for headers that start with `.#`. It adds the Mmark
extension, update the mmar test, adds some documentation.

I'm reusing the ast.Heading to have a maximum amount of code re-use.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-30 22:09:19 +01:00
Miek Gieben 0355745bf4 Ordered list: detect starting number
This keeps track of the starting number of an ordered list and uses it
when not zero. Fails the tests so it will probably have to wait until
we have the Mmark extension merged.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-30 09:09:41 +01:00
Miek Gieben aebf1c6233 Add block attributes
This adds the possibility to add block level attributes:

    {#id2}
    > line

When enabled to will generate (for HTML) an id="id2" in the openening
tag of the block quote:

    <blockquote id="id2">
    <p>line</p>
    </blockquote>

Only one block level attribute is allowed, if multiple are given only
the last one seen is applied, the rest is silently ignored.

The attributes are stored in *Parser and copied to the node in addBlock.
It's up to the renderer to use the attributes, the html renderer
currently applies them to most block level elements.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-30 08:42:38 +01:00
Krzysztof Kowalczyk 9bd36d810e add MathJax support; fixes #4 2018-04-15 23:34:22 -07:00
Krzysztof Kowalczyk 9059a41742 tweak comments in ast package 2018-02-01 13:19:44 -08:00
Krzysztof Kowalczyk e6baec3497 remove PanicIfContainer; it was incorrectly implemented and incorrectly used 2018-02-01 13:08:59 -08:00
Krzysztof Kowalczyk c1390b0a06 rename LastChild() => GetLastChild() etc. 2018-01-31 01:02:27 -08:00
Krzysztof Kowalczyk 2e57f7f6dc add cmd/printast and code to pretty-print ast 2018-01-28 16:16:11 -08:00
Krzysztof Kowalczyk 724ca64990 simplify implementation of Walk(); make LastChild(), FirstChild() stand-alone functions 2018-01-28 15:06:21 -08:00
Krzysztof Kowalczyk 35f86d5571 rename TreeNode => Container and LeafNode => Leaf 2018-01-28 05:13:46 -08:00
Krzysztof Kowalczyk d4a12c3518 better names 2018-01-28 02:46:13 -08:00
Krzysztof Kowalczyk a63ba13b3a improve names 2018-01-28 02:38:32 -08:00
Krzysztof Kowalczyk c8f7d7a9bd speed up, maybe, by a bit 2018-01-28 02:10:03 -08:00
Krzysztof Kowalczyk 50594ba490 remove Node.SetContent() 2018-01-28 02:02:41 -08:00
Krzysztof Kowalczyk 439dda2727 add LeafNode type 2018-01-28 01:41:19 -08:00
Krzysztof Kowalczyk 54d85c47da remove isNilNode() 2018-01-28 01:05:42 -08:00
Krzysztof Kowalczyk 242d66580e complete refactor 2018-01-28 00:50:21 -08:00
Krzysztof Kowalczyk 7e13677aaf Node.Open doesn't seem to be used 2018-01-27 21:06:38 -08:00
Krzysztof Kowalczyk 9e3c1a6830 add docs 2018-01-27 19:54:25 -08:00