Implement Markdown definition lists (+ migration) (#20333)

Implements definition lists Markdown extension adopted in a few
implementations including:
* [Pandoc](
  https://pandoc.org/MANUAL.html#definition-lists)
* [kramdown](
  https://kramdown.gettalong.org/quickref.html#definition-lists)
* [PHP extra Markdown](
  https://michelf.ca/projects/php-markdown/extra/#def-list)

Also affected files have been migrated.
RST definition lists are turned off for Markdown: this solves the
problem of broken formatting mentioned in
https://github.com/nim-lang/Nim/pull/20292.
This commit is contained in:
Andrey Makarov 2022-09-11 20:52:43 +03:00 • committed by GitHub
commit 088487f652
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 266 additions and 97 deletions

View file

@ -75,16 +75,16 @@ type
## comment".`
##
## `pattern: string`
## the string that was used to create the pattern. For details on how
## : the string that was used to create the pattern. For details on how
## to write a pattern, please see `the official PCRE pattern
## documentation.
## <https://www.pcre.org/original/doc/html/pcrepattern.html>`_
##
## `captureCount: int`
## the number of captures that the pattern has.
## : the number of captures that the pattern has.
##
## `captureNameId: Table[string, int]`
## a table from the capture names to their numeric id.
## : a table from the capture names to their numeric id.
##
##
## Options
@ -151,36 +151,36 @@ type
## execution. On failure, it is none, on success, it is some.
##
## `pattern: Regex`
## the pattern that is being matched
## : the pattern that is being matched
##
## `str: string`
## the string that was matched against
## : the string that was matched against
##
## `captures[]: string`
## the string value of whatever was captured at that id. If the value
## : the string value of whatever was captured at that id. If the value
## is invalid, then behavior is undefined. If the id is `-1`, then
## the whole match is returned. If the given capture was not matched,
## `nil` is returned. See examples for `match`.
##
## `captureBounds[]: HSlice[int, int]`
## gets the bounds of the given capture according to the same rules as
## : gets the bounds of the given capture according to the same rules as
## the above. If the capture is not filled, then `None` is returned.
## The bounds are both inclusive. See examples for `match`.
##
## `match: string`
## the full text of the match.
## : the full text of the match.
##
## `matchBounds: HSlice[int, int]`
## the bounds of the match, as in `captureBounds[]`
## : the bounds of the match, as in `captureBounds[]`
##
## `(captureBounds|captures).toTable`
## returns a table with each named capture as a key.
## : returns a table with each named capture as a key.
##
## `(captureBounds|captures).toSeq`
## returns all the captures by their number.
## : returns all the captures by their number.
##
## `$: string`
## same as `match`
## : same as `match`
pattern*: Regex ## The regex doing the matching.
## Not nil.
str*: string ## The string that was matched against.
@ -583,11 +583,11 @@ proc find*(str: string, pattern: Regex, start = 0, endpos = int.high): Option[Re
## positions.
##
## `start`
## The start point at which to start matching. `|abc` is `0`;
## : The start point at which to start matching. `|abc` is `0`;
## `a|bc` is `1`
##
## `endpos`
## The maximum index for a match; `int.high` means the end of the
## : The maximum index for a match; `int.high` means the end of the
## string, otherwise it’s an inclusive upper bound.
return str.matchImpl(pattern, start, endpos, 0)