Skip to content
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

ConTeXt writer: new section syntax and --section-divs #4295

Merged
merged 3 commits into from
Jan 25, 2018

Conversation

hmenke
Copy link
Contributor

@hmenke hmenke commented Jan 23, 2018

Fixes #2609.

This PR introduces the new-style section headings.

\section[my-header]{My Header} -> \section[title={My Header},reference={my-header}]

On top of this, the ConTeXt writer now supports the --section-divs option to write sections in the fenced style

\startsection[title={My Header},reference={my-header}]

contents...

\stopsection

@pmazaitis @ousia @DaveJarvis

@hmenke
Copy link
Contributor Author

hmenke commented Jan 23, 2018

This is not yet ideal. This piece of markdown

# Section
## Subsection
### Subsubsection
#### Subsubsubsection
##### Subsubsubsubsection
###### Subsubsubsubsubsection
####### Subsubsubsubsubsubssection

translates to

\section[title={Section},reference={section}]

\subsection[title={Subsection},reference={subsection}]

\subsubsection[title={Subsubsection},reference={subsubsection}]

\subsubsubsection[title={Subsubsubsection},reference={subsubsubsection}]

\subsubsubsubsection[title={Subsubsubsubsection},reference={subsubsubsubsection}]

\

\

The problem is not so much in the spurious backslashes but rather in the fact that even with the original behaviour section levels beyond 5 were silently discarded.

What should be the desired behaviour here? I would go for simply generating all those lower levels even if they are not predefined in ConTeXt. If the user wants to use such deep nesting they should just adapt their preamble.

@ghost
Copy link

ghost commented Jan 24, 2018

What should be the desired behaviour here? I would go for simply generating all those lower levels even if they are not predefined in ConTeXt. If the user wants to use such deep nesting they should just adapt their preamble.

There are a number of possibilities:

  • Define \stop and \start environments in the standalone preamble for the number of subsections encountered in the document that go beyond ConTeXt's default depth.
  • Create custom title levels so ######### Title generates a preamble with \definehead[section9][section], where 9 indicates the title level depth, so the output becomes \section9 ....
  • Introduce a \startsubject section, though this leaves a few issues: the subject sections are unnumbered and they wouldn't appear in the table of contents by default.
  • Exit with an error code and message that indicate the number of nested levels is not yet supported.

In any case, it's probably most convenient (and least astonishing) to update the standalone preamble with the environments that allow the output to generate a document with the titles that reflect the author's intent.

Also, nice work on the --section-divs!

@hmenke
Copy link
Contributor Author

hmenke commented Jan 24, 2018

@DaveJarvis

  1. Writing defintions for the deeply nested sections to the preamble is certainly possible but only works for standalone documents which include the preamble. Also it is not the prettiest solution.
  2. Definitely no.
  3. You can use pandoc also with unnumbered sections so this would clash.
  4. Isn't this the same as 1.?

I would just generate subsub...subsub and let the user worry about that. As you already mentioned, it's a weird edge case. There is also the subsub module to handle such deep nesting but it has some hick-ups.

@ghost
Copy link

ghost commented Jan 24, 2018

I would just generate subsub...subsub and let the user worry about that. There is also the subsub module...

That's a good idea. Perhaps output a warning, then, directing the user to see the subsub module in the event they have nested too deeply?

@jgm
Copy link
Owner

jgm commented Jan 24, 2018 via email

@hmenke
Copy link
Contributor Author

hmenke commented Jan 24, 2018

@jgm Done. I have also added a test for --section-divs.

@jgm jgm merged commit 751b5ad into jgm:master Jan 25, 2018
@jgm
Copy link
Owner

jgm commented Jan 25, 2018

Thanks, merged!

@hmenke hmenke deleted the section-divs branch January 25, 2018 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants