Skip to content

Commit

Permalink
Handle in-word underscores
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Jun 3, 2020
1 parent ef64405 commit 6c41888
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'rst_parser'
version = '0.3.1'
version = '0.3.2'
authors = ['Philipp A. <[email protected]>']
edition = '2018'
description = 'a reStructuredText parser'
Expand Down
2 changes: 1 addition & 1 deletion parser/src/rst.pest
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ literal = { (!("`"|" ") ~ inline_nested)+ ~ (" "+ ~ (!("`"|" ") ~ inline_
// inline links
reference = { reference_target | reference_explicit | reference_auto }

reference_target = { reference_target_uq ~ "_" | reference_target_qu }
reference_target = { (reference_target_uq ~ "_" | reference_target_qu) ~ !(LETTER|NUMBER) }
reference_target_uq = { (!("_"|":"|"`") ~ nonspacechar)+ }
reference_target_qu = { ( !("`"? ~ "`_") ~ "`" ~ !"``" ) ~ reference_text? ~ ("<" ~ reference_bracketed ~ ">")? ~ ( "`" ~ !"``" ) ~ "_" }
reference_text = { !"<" ~ ( !("`"|"<") ~ ANY )+ }
Expand Down
12 changes: 12 additions & 0 deletions parser/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ fn two_targets() {
};
}

#[test]
fn inline_code_literal_with_underscore() {
parses_to! {
parser: RstParser,
input: "``NAME_WITH_UNDERSCORE``",
rule: Rule::inline,
tokens: [
literal(2, 22, [str_nested(2, 22)]),
]
};
}

#[allow(clippy::cognitive_complexity)]
#[test]
fn admonitions() {
Expand Down

0 comments on commit 6c41888

Please sign in to comment.