Skip to content

Commit

Permalink
Allow additional text in theorem/proof environment names
Browse files Browse the repository at this point in the history
  • Loading branch information
edemaine committed Nov 15, 2023
1 parent 34bf564 commit eb417bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ instead of version numbers.
## 2023-11-15

* Support `\begin{hint}` / `\begin{hint+}` environments (for problem hints).
* Support extra text after theorem-like environments, for finer control.
For example, `\begin{theorem 1}` produces "Theorem 1", and
`\begin{proof sketch}` produces "Proof sketch".
By contrast, optional arguments add parentheses:
`\begin{theorem 1}` produces "Theorem (1)", and
`\begin{proof}[sketch]` produces "Proof (sketch)".

## 2023-11-01

Expand Down
8 changes: 4 additions & 4 deletions lib/formats.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,12 @@ latex2htmlCommandsAlpha = (tex, math) ->
#{prefix}}#{rest ? ''}
"""
.replace /(\\end\s*{[^{}]+)\+}/g, "$1}</details>"
.replace /\\begin\s*{(problem|question|idea|theorem|conjecture|lemma|corollary|fact|observation|proposition|claim|definition|example|remark|note|hint)}(\s*\[([^\]]*)\])?/g, (m, env, x, opt) -> """<blockquote#{if env in ['example', 'remark', 'note', 'hint'] then '' else ' class="thm"'}><p><b>#{capitalize env}#{if opt then " (#{opt})" else ''}:</b> """
.replace /\\end\s*{(problem|question|idea|theorem|conjecture|lemma|corollary|fact|observation|proposition|claim|definition|example|remark|note|hint)}/g, '</blockquote>'
.replace /\\begin\s*{(problem|question|idea|theorem|conjecture|lemma|corollary|fact|observation|proposition|claim|definition|example|remark|note|hint)([^{}]*)}(\s*\[([^\]]*)\])?/g, (m, env, rest, x, opt) -> """<blockquote#{if /^(example|remark|note|hint)/.test env then '' else ' class="thm"'}><p><b>#{capitalize env}#{rest}#{if opt then " (#{opt})" else ''}:</b> """
.replace /\\end\s*{(problem|question|idea|theorem|conjecture|lemma|corollary|fact|observation|proposition|claim|definition|example|remark|note|hint)([^{}]*)}/g, '</blockquote>'
.replace /\\begin\s*{(quote)}/g, '<blockquote><p>'
.replace /\\end\s*{(quote)}/g, '</blockquote>'
.replace /\\begin\s*{(proof|pf)}(\s*\[((?:[^\]{}]|{(?:[^{}]|{[^{}]*})})*)\])?/g, (m, env, x, opt) -> "<b>Proof#{if opt then " (#{opt})" else ''}:</b> "
.replace /\\end\s*{(proof|pf)}/g, ' <span class="pull-right">&#8718;</span></p><p class="clearfix">'
.replace /\\begin\s*{(proof|pf)([^{}]*)}(\s*\[((?:[^\]{}]|{(?:[^{}]|{[^{}]*})})*)\])?/g, (m, env, rest, x, opt) -> "<b>Proof#{rest}#{if opt then " (#{opt})" else ''}:</b> "
.replace /\\end\s*{(proof|pf)([^{}]*)}/g, ' <span class="pull-right">&#8718;</span></p><p class="clearfix">'
.replace /\\begin\s*{center}/g, '<div class="center">'
.replace /\\end\s*{center}/g, '</div>'
.replace latexSimpleCommandsRe, (match, name) -> latexSimpleCommands[name]
Expand Down

0 comments on commit eb417bb

Please sign in to comment.