Skip to content

Commit ae13af0

Browse files
committed
close #81: allow , and . in sub/superscripts
1 parent 8fc1d4d commit ae13af0

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: litedown
22
Type: Package
33
Title: A Lightweight Version of R Markdown
4-
Version: 0.6.4
4+
Version: 0.6.5
55
Authors@R: c(
66
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666", URL = "https://yihui.org")),
77
person("Tim", "Taylor", role = "ctb", comment = c(ORCID = "0000-0002-8587-7113")),

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- `pkg_manual()` will exclude help pages with the keyword `internal` (thanks, @TimTaylor, #78).
44

5+
- Allow `,` and `.` in superscripts and subscripts (thanks, @janlisec, #81).
6+
57
- Fixed a bug that inline code expressions (`` `{lang} expr` ``) cannot be correctly located when the line has leading spaces that are not meaningful.
68

79
# CHANGES IN litedown VERSION 0.6

R/mark.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ mark = function(input, output = NULL, text = NULL, options = NULL, meta = list()
158158
})
159159
# superscript and subscript; for now, we allow only characters alnum|*|(|) for
160160
# script text but can consider changing this rule upon users' request
161-
r2 = '(?<!`)\\^([[:alnum:]*()]+?)\\^(?!`)'
161+
r2 = '(?<!`)\\^([[:alnum:]*(),.]+?)\\^(?!`)'
162162
if (has_sup <- test_feature('superscript', r2)) {
163163
id2 = id_string(text)
164164
find_prose()
@@ -168,7 +168,7 @@ mark = function(input, output = NULL, text = NULL, options = NULL, meta = list()
168168
sprintf('!%s!', x)
169169
})
170170
}
171-
r3 = '(?<![~`[:space:]])~([[:alnum:]*()]+?)~(?!`)'
171+
r3 = '(?<![~`[:space:]])~([[:alnum:]*(),.]+?)~(?!`)'
172172
if (has_sub <- test_feature('subscript', r3)) {
173173
id3 = id_string(text)
174174
find_prose()

inst/examples/render-options.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ mark("~~awesome~~")
6060
mark("~~awesome~~", options = "-strikethrough")
6161

6262
# superscript and subscript examples
63-
mark("2^10^")
64-
mark("2^10^", options = "-superscript")
63+
mark("2^10.5^")
64+
mark("2^10.5^", options = "-superscript")
6565
mark("H~2~O")
6666
mark("H~2~O", options = "-subscript")
67+
mark("X~i,j~")
6768

6869
# code blocks
6970
mark('```r\n1 + 1;\n```')

tests/tests.Rout.save

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,21 @@ b</span></p>
140140
> mark("~~awesome~~", options = "-strikethrough")
141141
<p>~~awesome~~</p>
142142

143-
> mark("2^10^")
144-
<p>2<sup>10</sup></p>
143+
> mark("2^10.5^")
144+
<p>2<sup>10.5</sup></p>
145145

146-
> mark("2^10^", options = "-superscript")
147-
<p>2^10^</p>
146+
> mark("2^10.5^", options = "-superscript")
147+
<p>2^10.5^</p>
148148

149149
> mark("H~2~O")
150150
<p>H<sub>2</sub>O</p>
151151

152152
> mark("H~2~O", options = "-subscript")
153153
<p>H~2~O</p>
154154

155+
> mark("X~i,j~")
156+
<p>X<sub>i,j</sub></p>
157+
155158
> mark("```r\n1 + 1;\n```")
156159
<pre><code class="language-r">1 + 1;
157160
</code></pre>

0 commit comments

Comments
 (0)