Andrey Makarov
de9cbf6af1
Fix auto links to subheader when TOC is present ( #20279 )
...
Fix links to subheader when TOC is present
It was observed (in https://github.com/nim-lang/Nim/pull/20112 )
that links to 2nd- (and subsequent) -level headings
fail if TOC is present, e.g.:
```nim
.. contents::
Type relations
==============
Convertible relation
--------------------
Ref. `Convertible relation`_
```
The problem here is that links are resolved in `rst.nim` but later
`rstgen.nim` fixes ("fixes") anchors to make them unique so that
TOC always works (if e.g. there was another sub-section like
"Convertible relation").
The solution implemented in this PR is to move that fix-up of anchors
into `rst.nim`, so that link resolution could know final anchors.
The bug seems to be added in https://github.com/nim-lang/Nim/pull/2332
in 2015, that is it is present in Nim 1.0.
2022-08-27 17:28:26 -04:00
ringabout
b6bfe38ff5
move formatfloat out of system ( #20195 )
...
* move formatfloat out of system
* fixes doc
* Update changelog.md
* careless
* fixes
* deprecate system/formatfloat
* better handling
2022-08-24 13:38:30 +02:00
Andrey Makarov
14656154ef
Add doctype: RST|Markdown|RstMarkdown pragma ( #20252 )
...
* Add `doctype: RST|Markdown|RstMarkdown` pragma
Implements https://github.com/nim-lang/RFCs/issues/68 ,
see also discussion in https://github.com/nim-lang/Nim/issues/17987
The permitted values:
* `markdown`, which is default. It still contains nearly all of
the RST supported but it is assumed that in time we will give up
most or all RST features in this mode
* `rst`, without any extensions
* `RstMarkdown` — compatibility with Nim 1.x. It's basically RST
with those Markdown features enabled that don't conflict with RST.
* Apply suggestions from code review
Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com >
* Additional fix in spirit of review
* Fix test after #20188
Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com >
2022-08-23 14:49:53 -04:00
Andrey Makarov
9f408ea943
Don't require blank line before Markdown code ( #20215 )
...
Fixes bug reported in https://github.com/nim-lang/Nim/pull/20189
affecting nimforum.
2022-08-15 18:37:45 -04:00
ringabout
e8ae2dc90b
bootstrap the compiler with nimPreviewSlimSystem ( #20176 )
...
* bootstrap the compiler with nimPreviewSlimSystem
* threads
2022-08-09 16:32:29 +08:00
Andrey Makarov
40e0048a50
Highlight Nim default in Markdown code in .nim ( #20110 )
...
Highlight Nim by default in Markdown code in .nim
2022-07-31 15:38:00 +02:00
Andrey Makarov
62b81d7f10
Markdown code blocks part 2; migrate Nim Manual ( #20080 )
...
* Change headings underscored by `~~~` to `###`
* Markdown code blocks part 2; migrate Nim Manual
2022-07-25 18:29:52 +02:00
Andrey Makarov
417b90a7e5
Improve Markdown code blocks & start moving docs to Markdown style ( #19954 )
...
- add additional parameters parsing (other implementations will just
ignore them). E.g. if in RST we have:
.. code:: nim
:test: "nim c $1"
...
then in Markdown that will be:
```nim test="nim c $1"
...
```
- implement Markdown interpretation of additional indentation which is
less than 4 spaces (>=4 spaces is a code block but it's not
implemented yet). RST interpretes it as quoted block, for Markdown it's
just normal paragraphs.
- add separate `md2html` and `md2tex` commands. This is to separate
Markdown behavior in cases when it diverges w.r.t. RST significantly —
most conspicously like in the case of additional indentation above, and
also currently the contradicting inline rule of Markdown is also turned
on only in `md2html` and `md2tex`. **Rationale:** mixing Markdown and
RST arbitrarily is a way to nowhere, we need to provide a way to fix the
particular behavior. Note that still all commands have **both** Markdown
and RST features **enabled**. In this PR `*.nim` files can be processed
only in Markdown mode, while `md2html` is for `*.md` files and
`rst2html` for `*.rst` files.
- rename `*.rst` files to `.*md` as our current default behavior is
already Markdown-ish
- convert code blocks in `docgen.rst` to Markdown style as an example.
Other code blocks will be converted in the follow-up PRs
- fix indentation inside Markdown code blocks — additional indentation
is preserved there
- allow more than 3 backticks open/close blocks (tildas \~ are still not
allowed to avoid conflict with RST adornment headings) see also
https://github.com/nim-lang/RFCs/issues/355
- better error messages
- (other) fix a bug that admonitions cannot be used in sandbox mode; fix
annoying warning on line 2711
2022-07-15 19:27:54 +02:00
Andrey Makarov
4341b06f65
RST: improve simple tables ( #19859 )
...
* RST: improve simple tables
* nim 1.0 gotchas
* Still allow legacy boundaries like `----`
2022-06-04 07:03:03 +02:00
Andrey Makarov
801c0f0369
Fix bug 27 of #17340 ( #19433 )
...
Fixes silent disappearance of Markdown (pseudo-)link when it's detected as
unsafe protocol. Now it will be converted to plain text in spirit of
[the specification](https://spec.commonmark.org/0.30/#links ).
For that sake the check for protocol is added to rst.nim also.
2022-02-07 18:11:53 -05:00
Dominik Picheta
cb894c7094
Merge pull request from GHSA-ggrq-h43f-3w7m
...
This fixes a CVE (currently
https://github.com/nim-lang/Nim/security/advisories/GHSA-ggrq-h43f-3w7m )
2022-01-29 14:03:01 +01:00
Andreas Rumpf
15f54de5c4
RST: allow empty number-lines directives just like it was done for a decade; all my documents rely on this feature [backport ( #19431 )
2022-01-22 20:33:55 +01:00
flywind
ada815e459
make rst thread safe ( #19369 )
...
split for the convenience of review
2022-01-13 08:03:14 +01:00
Andrey Makarov
19898e1225
Fix group reference (with capital letters ( #19196 )
...
in group name)
2021-12-20 15:10:15 -05:00
Andreas Rumpf
9338aa2497
fixes a possible 'javascript:' protocol exploit [backport:1.0] ( #19134 )
...
* fixes a possible 'javascript:' protocol exploit [backport:1.0]
* add tests
* Update tests/stdlib/trstgen.nim
* add the same logic for hyperlinks
* move the logic into a proc
Co-authored-by: narimiran <narimiran@disroot.org >
2021-12-10 09:24:20 +01:00
Andrey Makarov
040d23e799
implement RST & Markdown quote blocks ( #19147 )
...
* implement RST & Markdown quote blocks
* compile with nim 1.0
* Fix indentation
2021-11-23 13:02:03 +01:00
Andrey Makarov
997ccc5889
fix nimindexterm in rst2tex/doc2tex [backport] ( #19106 )
...
* fix nimindexterm (rst2tex/doc2tex) [backport]
* Add support for indexing in rst
2021-11-09 19:01:47 +01:00
Andrey Makarov
b21eb1ed36
change os.nim doc links to new style ( #19102 )
2021-11-08 13:10:01 +01:00
Andrey Makarov
7ba2659f73
docgen: implement doc link resolution in current module ( #18642 )
2021-10-28 19:20:52 +02:00
Andrey Makarov
f03872d99e
rst: minor fixes ( #18960 )
2021-10-06 13:53:01 +02:00
Andreas Rumpf
e9268b52d9
with this patch :idx: can be used for the index generation for LaTeX ( #18946 )
2021-10-03 07:21:08 +02:00
flywind
c6fadb1799
[minor] reduce substr ( #18611 )
...
* minor
* correct
* unify the type of addrLen
* Update lib/packages/docutils/rstgen.nim
2021-07-30 09:32:00 +02:00
Andrey Makarov
8c7ee96457
rst: add missing line/column info for some warnings ( #18383 )
...
* rst: add missing line/column info for some warnings
* add workaround
* use TLineInfo/FileIndex for storing file names
* fix blank lines in include file (rm harmful strip)
* don't use ref TLineInfo
* return `hasToc` as output parameter for uniformity
* Update compiler/docgen.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* Update compiler/docgen.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* Update lib/packages/docutils/rst.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* address review - stylistic things
* Update compiler/docgen.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* unify RST warnings/errors names
* doAssert + minor name change
* fix a bug caught by doAssert
* apply strbasics.strip to final HTML/Latex
* rm redundant filename
* fix test after rebase
* delete `order` from rnFootnoteRef,
also display errors/warnings properly when footnote references are from
different files
* Update compiler/lineinfos.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* Update lib/packages/docutils/rstast.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* Update lib/packages/docutils/rstast.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* Update lib/packages/docutils/rstast.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* revert because of error:
Error: cannot prove that it's safe to initialize 'info' with the runtime value for the discriminator 'kind'
* Update lib/packages/docutils/rstgen.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* apply suggestion
* Update lib/packages/docutils/rst.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* add Table for string->file name mapping
* do not import compiler/lineinfos
* fix ambiguous calls
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
Co-authored-by: narimiran <narimiran@disroot.org >
2021-07-20 08:32:22 +02:00
Andrey Makarov
0e44d137f9
rm redundant blank lines before literal blocks ( #18465 )
2021-07-08 20:24:57 -04:00
Bung
16f0b55664
remove isKeywordIgnoreCase from highlite, not used , can't even compile with -d:useNimRtl ( #18399 )
2021-06-30 07:28:41 +02:00
Andrey Makarov
1b9b806007
rst: fix bug 20 from #17340 ( #18360 )
...
and a leftover bug: priority of option list inside definition list
2021-06-26 18:10:46 +02:00
Andrey Makarov
0c8d3ae985
rst: allow comment to continue on second line ( #18338 )
2021-06-24 10:28:28 +02:00
Andrey Makarov
9c43f05099
Markdown: allow to end URL with balanced parenthesis ( #18321 )
...
* Markdown: allow to end URL with balanced parenthesis
* Update lib/packages/docutils/rst.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* apply suggestion
* remove unnecessary if
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
2021-06-23 07:50:05 +02:00
Andrey Makarov
1b3c0f142d
validate rst field for :number-lines:, :status: ( #18304 )
2021-06-20 20:00:42 +02:00
Andrey Makarov
590d457631
docgen: move to shared RST state ( fix #16990 ) ( #18256 )
...
* docgen: move to shared RST state (fix #16990 )
* Update lib/packages/docutils/rst.nim
Co-authored-by: Andreas Rumpf <rumpf_a@web.de >
* Update lib/packages/docutils/rst.nim
Co-authored-by: Andreas Rumpf <rumpf_a@web.de >
* Update lib/packages/docutils/rst.nim
Co-authored-by: Andreas Rumpf <rumpf_a@web.de >
* Update compiler/docgen.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* Update compiler/docgen.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* Update compiler/docgen.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* Update lib/packages/docutils/rst.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* rename `cmdDoc2` to `cmdDoc`
* fix (P)RstSharedState convention
* new style of initialization
* misc suggestions
* 1 more rename
* fix a regression
Co-authored-by: Andreas Rumpf <rumpf_a@web.de >
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
2021-06-20 09:50:03 +02:00
Andrey Makarov
9c0666e0bb
rst: remove roSkipPounds option ( #18175 )
2021-06-05 09:12:37 +02:00
Andrey Makarov
ba3ec7b049
docs: Latex generation improvements ( #18141 )
...
* docs: improve Latex generation
* make it work on Windows + fix ] escaping
* minor fixes with escapes and style
2021-06-01 20:47:23 +02:00
Andrey Makarov
9f7e2e3057
docs: make inline markup more compatible with Markdown ( #18053 )
...
fixes https://github.com/timotheecour/Nim/issues/739
2021-05-21 06:54:20 +02:00
Andrey Makarov
2096490b59
follow-up #17930 - inline syntax highlighting ( #18013 )
...
* follow-up #17930 - inline syntax highlighting
* make closure->nimcall
2021-05-16 23:55:14 +02:00
Andrey Makarov
3824fd3f9a
RST opt.list to have priority over def.list ( #17845 )
2021-05-15 08:12:26 +02:00
Andrey Makarov
97970d9dcc
doc2tex: generate docs to Latex (#17997 )
...
* `doc2tex`: generate docs to Latex
* address some comments
2021-05-14 07:30:47 +02:00
Andrey Makarov
436af88d8c
follow-up #17837 : add Console for interactive sessions ( #17930 )
...
* follow-up #17837 : add `Console` for interactive sessions
* fix Latex
2021-05-06 10:58:01 +02:00
Andrey Makarov
287f1170ba
highlite: fix #17890 - tokenize Nim escape seq-s ( #17919 )
...
* highlite: fix #17890 - tokenize Nim escape seq-s
* Update tests/stdlib/thighlite.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
2021-05-03 10:21:36 +02:00
Andrey Makarov
abb8a73134
Fix nim-lang/nimforum#285 - punctuation after URL ( #17908 )
...
* Fix nim-lang/nimforum#285 - punctuation after URL
* keep only one leaf in a rnStandaloneHyperlink
* add more complex URL
2021-05-01 07:20:33 +02:00
Timothee Cour
3192995ac9
close #16646 ; since now works with bootstrap nim post csources_v1 ( #17895 )
...
* revive #16627 now that csources_v1 was merged
* use dedent in rst.nim, refs https://github.com/nim-lang/Nim/pull/17257#discussion_r589025683
* fix test and improve rendering of a rst warning
2021-04-30 18:54:47 +02:00
Andrey Makarov
1640508348
more strict RST inline markup parsing ( #17827 )
...
* more strict RST inline markup parsing
* add test for unexpected bonus
* introduce `roPreferMarkdown`
2021-04-29 17:31:15 +02:00
Andrey Makarov
8f79bc5f3d
add RST highlighting for command line / shells (also fixes #16858 ) ( #17789 )
2021-04-21 16:57:54 +02:00
Andrey Makarov
f8dce493d3
rst indentation fixes (ref #17340 ) ( #17715 )
2021-04-15 08:12:44 +02:00
Andrey Makarov
2150cd1826
restyle RST option lists ( #17637 )
...
* WIP: restyle RST option lists
* apply similar style to Latex
* fix tests
* minor visual tweaks
* update tests
* remove leftover comments
2021-04-10 09:49:01 +02:00
Andrey Makarov
42687457b0
further progress on rst roles & directives ( fix #17646 ) ( #17659 )
...
* further progress on rst roles & dir-s (fix #17646 )
* fix documents according to the messages
* fix bug 17 from #17340
2021-04-08 19:00:14 +02:00
Andrey Makarov
ca405167ed
fix :number-lines: regression ( #17639 )
2021-04-05 08:33:06 +02:00
Andrey Makarov
f02e159b56
fix rst option list at EOF (follow-up #17442 ) ( #17638 )
2021-04-04 11:54:26 -07:00
Andrey Makarov
e35946f306
enable syntax highlighting for inline code ( #17585 )
...
* enable syntax highlighting for inline code
* finish '.. default-role' and preliminary '.. role'
implementation
* more compact check in dirRole
* set :literal: as default role for *.rst
* Update lib/packages/docutils/rst.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* use whichRole for setting currRoleKind
* Update lib/packages/docutils/rst.nim
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
* rename rnGeneralRole -> rnUnknownRole
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com >
2021-04-02 22:11:44 +02:00
Andrey Makarov
861c42c258
RST: enable parsing of prefix roles (ref #17340 ) ( #17514 )
2021-03-29 18:32:49 +02:00
Timothee Cour
8b26b3ad0d
remove docutils.nimble (not a real nimble package, and affected canonical imports) ( #17544 )
...
* remove docutils.nimble (not a real nimble package, and affected canonical imports)
* cleanup redundant references
2021-03-29 12:46:53 +02:00