Skip to content

Commit 5293f4f

Browse files
authored
Merge pull request #560 from kivikakk/push-pvonxwkovzuo
experimental-inline-sourcepos: not really experimental any more!
2 parents 719a162 + a8b1e83 commit 5293f4f

File tree

9 files changed

+51
-127
lines changed

9 files changed

+51
-127
lines changed

src/cm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,9 @@ impl<'a, 'o, 'c> CommonMarkFormatter<'a, 'o, 'c> {
655655
{
656656
self.cr();
657657
} else if self.options.render.hardbreaks {
658-
self.output(&[b'\n'], allow_wrap, Escaping::Literal);
658+
self.output(b"\n", allow_wrap, Escaping::Literal);
659659
} else {
660-
self.output(&[b' '], allow_wrap, Escaping::Literal);
660+
self.output(b" ", allow_wrap, Escaping::Literal);
661661
}
662662
}
663663
}
@@ -798,7 +798,7 @@ impl<'a, 'o, 'c> CommonMarkFormatter<'a, 'o, 'c> {
798798
write!(self, "](").unwrap();
799799
self.output(nl.url.as_bytes(), false, Escaping::Url);
800800
if !nl.title.is_empty() {
801-
self.output(&[b' ', b'"'], allow_wrap, Escaping::Literal);
801+
self.output(b" \"", allow_wrap, Escaping::Literal);
802802
self.output(nl.title.as_bytes(), false, Escaping::Title);
803803
write!(self, "\"").unwrap();
804804
}

src/html.rs

Lines changed: 16 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,9 @@ fn render_code<'a, T>(
498498
panic!()
499499
};
500500

501-
// Unreliable sourcepos.
502501
if entering {
503502
context.write_all(b"<code")?;
504-
if context.options.render.experimental_inline_sourcepos {
505-
render_sourcepos(context, node)?;
506-
}
503+
render_sourcepos(context, node)?;
507504
context.write_all(b">")?;
508505
context.escape(literal.as_bytes())?;
509506
context.write_all(b"</code>")?;
@@ -609,12 +606,9 @@ fn render_emph<'a, T>(
609606
node: &'a AstNode<'a>,
610607
entering: bool,
611608
) -> io::Result<ChildRendering> {
612-
// Unreliable sourcepos.
613609
if entering {
614610
context.write_all(b"<em")?;
615-
if context.options.render.experimental_inline_sourcepos {
616-
render_sourcepos(context, node)?;
617-
}
611+
render_sourcepos(context, node)?;
618612
context.write_all(b">")?;
619613
} else {
620614
context.write_all(b"</em>")?;
@@ -746,15 +740,12 @@ fn render_image<'a, T>(
746740
panic!()
747741
};
748742

749-
// Unreliable sourcepos.
750743
if entering {
751744
if context.options.render.figure_with_caption {
752745
context.write_all(b"<figure>")?;
753746
}
754747
context.write_all(b"<img")?;
755-
if context.options.render.experimental_inline_sourcepos {
756-
render_sourcepos(context, node)?;
757-
}
748+
render_sourcepos(context, node)?;
758749
context.write_all(b" src=\"")?;
759750
let url = nl.url.as_bytes();
760751
if context.options.render.unsafe_ || !dangerous_url(url) {
@@ -807,12 +798,9 @@ fn render_line_break<'a, T>(
807798
node: &'a AstNode<'a>,
808799
entering: bool,
809800
) -> io::Result<ChildRendering> {
810-
// Unreliable sourcepos.
811801
if entering {
812802
context.write_all(b"<br")?;
813-
if context.options.render.experimental_inline_sourcepos {
814-
render_sourcepos(context, node)?;
815-
}
803+
render_sourcepos(context, node)?;
816804
context.write_all(b" />\n")?;
817805
}
818806

@@ -828,7 +816,6 @@ fn render_link<'a, T>(
828816
panic!()
829817
};
830818

831-
// Unreliable sourcepos.
832819
let parent_node = node.parent();
833820

834821
if !context.options.parse.relaxed_autolinks
@@ -840,9 +827,7 @@ fn render_link<'a, T>(
840827
{
841828
if entering {
842829
context.write_all(b"<a")?;
843-
if context.options.render.experimental_inline_sourcepos {
844-
render_sourcepos(context, node)?;
845-
}
830+
render_sourcepos(context, node)?;
846831
context.write_all(b" href=\"")?;
847832
let url = nl.url.as_bytes();
848833
if context.options.render.unsafe_ || !dangerous_url(url) {
@@ -954,13 +939,10 @@ fn render_soft_break<'a, T>(
954939
node: &'a AstNode<'a>,
955940
entering: bool,
956941
) -> io::Result<ChildRendering> {
957-
// Unreliable sourcepos.
958942
if entering {
959943
if context.options.render.hardbreaks {
960944
context.write_all(b"<br")?;
961-
if context.options.render.experimental_inline_sourcepos {
962-
render_sourcepos(context, node)?;
963-
}
945+
render_sourcepos(context, node)?;
964946
context.write_all(b" />\n")?;
965947
} else {
966948
context.write_all(b"\n")?;
@@ -975,17 +957,14 @@ fn render_strong<'a, T>(
975957
node: &'a AstNode<'a>,
976958
entering: bool,
977959
) -> io::Result<ChildRendering> {
978-
// Unreliable sourcepos.
979960
let parent_node = node.parent();
980961
if !context.options.render.gfm_quirks
981962
|| (parent_node.is_none()
982963
|| !matches!(parent_node.unwrap().data.borrow().value, NodeValue::Strong))
983964
{
984965
if entering {
985966
context.write_all(b"<strong")?;
986-
if context.options.render.experimental_inline_sourcepos {
987-
render_sourcepos(context, node)?;
988-
}
967+
render_sourcepos(context, node)?;
989968
context.write_all(b">")?;
990969
} else {
991970
context.write_all(b"</strong>")?;
@@ -1069,17 +1048,14 @@ fn render_footnote_reference<'a, T>(
10691048
panic!()
10701049
};
10711050

1072-
// Unreliable sourcepos.
10731051
if entering {
10741052
let mut ref_id = format!("fnref-{}", nfr.name);
10751053
if nfr.ref_num > 1 {
10761054
ref_id = format!("{}-{}", ref_id, nfr.ref_num);
10771055
}
10781056

10791057
context.write_all(b"<sup")?;
1080-
if context.options.render.experimental_inline_sourcepos {
1081-
render_sourcepos(context, node)?;
1082-
}
1058+
render_sourcepos(context, node)?;
10831059
context.write_all(b" class=\"footnote-ref\"><a href=\"#fn-")?;
10841060
context.escape_href(nfr.name.as_bytes())?;
10851061
context.write_all(b"\" id=\"")?;
@@ -1095,12 +1071,9 @@ fn render_strikethrough<'a, T>(
10951071
node: &'a AstNode<'a>,
10961072
entering: bool,
10971073
) -> io::Result<ChildRendering> {
1098-
// Unreliable sourcepos.
10991074
if entering {
11001075
context.write_all(b"<del")?;
1101-
if context.options.render.experimental_inline_sourcepos {
1102-
render_sourcepos(context, node)?;
1103-
}
1076+
render_sourcepos(context, node)?;
11041077
context.write_all(b">")?;
11051078
} else {
11061079
context.write_all(b"</del>")?;
@@ -1353,13 +1326,10 @@ fn render_escaped<'a, T>(
13531326
node: &'a AstNode<'a>,
13541327
entering: bool,
13551328
) -> io::Result<ChildRendering> {
1356-
// Unreliable sourcepos.
13571329
if context.options.render.escaped_char_spans {
13581330
if entering {
13591331
context.write_all(b"<span data-escaped-char")?;
1360-
if context.options.render.experimental_inline_sourcepos {
1361-
render_sourcepos(context, node)?;
1362-
}
1332+
render_sourcepos(context, node)?;
13631333
context.write_all(b">")?;
13641334
} else {
13651335
context.write_all(b"</span>")?;
@@ -1416,9 +1386,7 @@ pub fn render_math<'a, T>(
14161386

14171387
tag_attributes.push((String::from("data-math-style"), String::from(style_attr)));
14181388

1419-
// Unreliable sourcepos.
1420-
if context.options.render.experimental_inline_sourcepos && context.options.render.sourcepos
1421-
{
1389+
if context.options.render.sourcepos {
14221390
let ast = node.data.borrow();
14231391
tag_attributes.push(("data-sourcepos".to_string(), ast.sourcepos.to_string()));
14241392
}
@@ -1526,12 +1494,9 @@ fn render_spoiler_text<'a, T>(
15261494
node: &'a AstNode<'a>,
15271495
entering: bool,
15281496
) -> io::Result<ChildRendering> {
1529-
// Unreliable sourcepos.
15301497
if entering {
15311498
context.write_all(b"<span")?;
1532-
if context.options.render.experimental_inline_sourcepos {
1533-
render_sourcepos(context, node)?;
1534-
}
1499+
render_sourcepos(context, node)?;
15351500
context.write_all(b" class=\"spoiler\">")?;
15361501
} else {
15371502
context.write_all(b"</span>")?;
@@ -1545,12 +1510,9 @@ fn render_subscript<'a, T>(
15451510
node: &'a AstNode<'a>,
15461511
entering: bool,
15471512
) -> io::Result<ChildRendering> {
1548-
// Unreliable sourcepos.
15491513
if entering {
15501514
context.write_all(b"<sub")?;
1551-
if context.options.render.experimental_inline_sourcepos {
1552-
render_sourcepos(context, node)?;
1553-
}
1515+
render_sourcepos(context, node)?;
15541516
context.write_all(b">")?;
15551517
} else {
15561518
context.write_all(b"</sub>")?;
@@ -1564,12 +1526,9 @@ fn render_superscript<'a, T>(
15641526
node: &'a AstNode<'a>,
15651527
entering: bool,
15661528
) -> io::Result<ChildRendering> {
1567-
// Unreliable sourcepos.
15681529
if entering {
15691530
context.write_all(b"<sup")?;
1570-
if context.options.render.experimental_inline_sourcepos {
1571-
render_sourcepos(context, node)?;
1572-
}
1531+
render_sourcepos(context, node)?;
15731532
context.write_all(b">")?;
15741533
} else {
15751534
context.write_all(b"</sup>")?;
@@ -1583,12 +1542,9 @@ fn render_underline<'a, T>(
15831542
node: &'a AstNode<'a>,
15841543
entering: bool,
15851544
) -> io::Result<ChildRendering> {
1586-
// Unreliable sourcepos.
15871545
if entering {
15881546
context.write_all(b"<u")?;
1589-
if context.options.render.experimental_inline_sourcepos {
1590-
render_sourcepos(context, node)?;
1591-
}
1547+
render_sourcepos(context, node)?;
15921548
context.write_all(b">")?;
15931549
} else {
15941550
context.write_all(b"</u>")?;
@@ -1606,12 +1562,9 @@ fn render_wiki_link<'a, T>(
16061562
panic!()
16071563
};
16081564

1609-
// Unreliable sourcepos.
16101565
if entering {
16111566
context.write_all(b"<a")?;
1612-
if context.options.render.experimental_inline_sourcepos {
1613-
render_sourcepos(context, node)?;
1614-
}
1567+
render_sourcepos(context, node)?;
16151568
context.write_all(b" href=\"")?;
16161569
let url = nl.url.as_bytes();
16171570
if context.options.render.unsafe_ || !dangerous_url(url) {

src/main.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,6 @@ struct Cli {
145145
#[arg(long)]
146146
sourcepos: bool,
147147

148-
/// Include inline sourcepos in HTML output, which is known to have issues.
149-
#[arg(long)]
150-
experimental_inline_sourcepos: bool,
151-
152148
/// Ignore setext headers
153149
#[arg(long)]
154150
ignore_setext: bool,
@@ -300,7 +296,6 @@ fn main() -> Result<(), Box<dyn Error>> {
300296
.escape(cli.escape)
301297
.list_style(cli.list_style.into())
302298
.sourcepos(cli.sourcepos)
303-
.experimental_inline_sourcepos(cli.experimental_inline_sourcepos)
304299
.experimental_minimize_commonmark(cli.experimental_minimize_commonmark)
305300
.escaped_char_spans(cli.escaped_char_spans)
306301
.ignore_setext(cli.ignore_setext)

src/parser/inlines.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<'a, 'r, 'o, 'd, 'i, 'c> Subject<'a, 'r, 'o, 'd, 'i, 'c> {
183183
if options.extension.spoiler {
184184
s.special_chars[b'|' as usize] = true;
185185
}
186-
for &c in &[b'"', b'\'', b'.', b'-'] {
186+
for &c in b"\"'.-" {
187187
s.smart_chars[c as usize] = true;
188188
}
189189
s
@@ -1622,7 +1622,7 @@ impl<'a, 'r, 'o, 'd, 'i, 'c> Subject<'a, 'r, 'o, 'd, 'i, 'c> {
16221622
.text()
16231623
.unwrap()
16241624
.as_bytes()
1625-
.starts_with(&[b'^'])
1625+
.starts_with(b"^")
16261626
} else {
16271627
false
16281628
}

0 commit comments

Comments
 (0)