-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generate: demote headings, and group link reference definitions #620
Commits on Jun 19, 2022
-
generate: demote level of non-first headers
To-do: update the integration tests accordingly. Closes: 328
Configuration menu - View commit details
-
Copy full SHA for a098a9c - Browse repository at this point
Copy the full SHA a098a9cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8e4bc8a - Browse repository at this point
Copy the full SHA 8e4bc8aView commit details -
Configuration menu - View commit details
-
Copy full SHA for b62775e - Browse repository at this point
Copy the full SHA b62775eView commit details -
generate: don't alter
#
line inside fenced code blockPreviously, `configlet generate` assumed that every line beginning with a '#' character inside a concept `introduction.md` is a header. For our purposes, the most common exception to that idea is probably a comment inside a fenced code block. With this commit, we no longer add a '#' to such a line. The markdown handling here is rudimentary, but it may be good enough to avoid a full markdown parser for `configlet generate`. But this doesn't support other blocks, like HTML blocks.
Configuration menu - View commit details
-
Copy full SHA for 5284615 - Browse repository at this point
Copy the full SHA 5284615View commit details -
generate: add starting level-2 heading with concept's name
Also update the tests to assert that `configlet generate` makes no changes to the current state of the elixir track repo. In a later PR we'll update those tests to assert the same for `configlet generate -uy`.
Configuration menu - View commit details
-
Copy full SHA for cb47886 - Browse repository at this point
Copy the full SHA cb47886View commit details
Commits on Jun 22, 2022
-
This is arguable. But I think this way is more readable overall by the time we add handling of HTML comment blocks.
Configuration menu - View commit details
-
Copy full SHA for 2f65060 - Browse repository at this point
Copy the full SHA 2f65060View commit details -
generate: refactor via
continuesWith
More readable, and easier to extend to support HTML comment blocks, but probably marginally slower.
Configuration menu - View commit details
-
Copy full SHA for 118fd27 - Browse repository at this point
Copy the full SHA 118fd27View commit details -
generate: support HTML comment block
This is only one of many possible HTML blocks [1], but probably the most important one. [1] https://spec.commonmark.org/0.30/#html-blocks
Configuration menu - View commit details
-
Copy full SHA for da1d695 - Browse repository at this point
Copy the full SHA da1d695View commit details -
generate: don't insert h2 when under h2; demote dynamically
Insert a h2 using the concept's name in the track `config.json`, and demote the headers in the `introduction.md` for the `foo` concept by 1: # Introduction %{concept:foo} Don't insert a h2, and demote by 1: # Introduction ## Foo %{concept:foo} Don't insert a h2, and demote by 2: # Introduction ## Some header Blah blah. ### Foo %{concept:foo}
Configuration menu - View commit details
-
Copy full SHA for 3a514c2 - Browse repository at this point
Copy the full SHA 3a514c2View commit details -
Configuration menu - View commit details
-
Copy full SHA for d7cea65 - Browse repository at this point
Copy the full SHA d7cea65View commit details
Commits on Jun 24, 2022
-
Configuration menu - View commit details
-
Copy full SHA for ff23522 - Browse repository at this point
Copy the full SHA ff23522View commit details -
Configuration menu - View commit details
-
Copy full SHA for dc291af - Browse repository at this point
Copy the full SHA dc291afView commit details -
generate: put all reference links at the bottom
Consider this `.md.tpl` file: # Introduction ## Foo %{concept:foo} ## Bar %{concept:bar} Before this commit, when more than one placeholder had a reference link, `configlet generate` would produce something like # Introduction ## Foo Here is a line with a link [Foo][foo]. [foo]: http://www.example.com ## Bar Here is another line with a link [Bar][bar]. [bar]: http://www.example.com With this commit, we place the reference links at the bottom, ordering by first usage, and deduplicating them: # Introduction ## Foo Here is a line with a link [Foo][foo]. ## Bar Here is another line with a link [Bar][bar]. [foo]: http://www.example.com [bar]: http://www.example.com But it's tricky to do this robustly without using a proper markdown parser. From the CommonMark Spec [1], the rules for reference links have some complexity: A link reference definition consists of a link label, optionally preceded by up to three spaces of indentation, followed by a colon (:), optional spaces or tabs (including up to one line ending), a link destination, optional spaces or tabs (including up to one line ending), and an optional link title, which if it is present must be separated from the link destination by spaces or tabs. No further character may occur. --- A link label begins with a left bracket ([) and ends with the first right bracket (]) that is not backslash-escaped. Between these brackets there must be at least one character that is not a space, tab, or line ending. Unescaped square bracket characters are not allowed inside the opening and closing square brackets of link labels. A link label can have at most 999 characters inside the square brackets. [1] https://spec.commonmark.org/0.30/#link-reference-definitions
Configuration menu - View commit details
-
Copy full SHA for 42a8d14 - Browse repository at this point
Copy the full SHA 42a8d14View commit details
Commits on Jun 28, 2022
-
generate: rename
getSlugLookup
procClarify the kind of slug. In the future we could even consider: type ConceptSlug* = distinct string ExerciseSlug* = distinct string
Configuration menu - View commit details
-
Copy full SHA for d1a1ab1 - Browse repository at this point
Copy the full SHA d1a1ab1View commit details -
generate: rename
header
toheading
The CommonMark spec [1] calls them headings, not headers. [1] https://spec.commonmark.org/0.30/
Configuration menu - View commit details
-
Copy full SHA for 394221c - Browse repository at this point
Copy the full SHA 394221cView commit details -
generate: move
writeError
proc downMake declaration order match usage order.
Configuration menu - View commit details
-
Copy full SHA for 3b0afc2 - Browse repository at this point
Copy the full SHA 3b0afc2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0d88452 - Browse repository at this point
Copy the full SHA 0d88452View commit details -
Configuration menu - View commit details
-
Copy full SHA for 94878f0 - Browse repository at this point
Copy the full SHA 94878f0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 42b1460 - Browse repository at this point
Copy the full SHA 42b1460View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5d333b8 - Browse repository at this point
Copy the full SHA 5d333b8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 09f4fca - Browse repository at this point
Copy the full SHA 09f4fcaView commit details -
The backticks look a bit strange, even if you know that `concept` is a keyword. Sidestep the issue. We named it `con` elsewhere: $ git grep --heading --break 'for .* in concepts:' src/info/info.nim 32: for con in concepts: src/lint/track_config.nim 303: for con in concepts:
Configuration menu - View commit details
-
Copy full SHA for c244d1a - Browse repository at this point
Copy the full SHA c244d1aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1ecc512 - Browse repository at this point
Copy the full SHA 1ecc512View commit details -
Configuration menu - View commit details
-
Copy full SHA for 607f369 - Browse repository at this point
Copy the full SHA 607f369View commit details -
generate: refer to "link reference definitions"
That's what the CommonMark Spec [1] calls them. [1] https://spec.commonmark.org/0.30/#link-reference-definitions
Configuration menu - View commit details
-
Copy full SHA for 4ee45ef - Browse repository at this point
Copy the full SHA 4ee45efView commit details
Commits on Jun 30, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 7727f73 - Browse repository at this point
Copy the full SHA 7727f73View commit details