Skip to content

Commit

Permalink
add support for converting crossreferences and strong emphasis
Browse files Browse the repository at this point in the history
  • Loading branch information
pennae committed Aug 3, 2022
1 parent 44c2719 commit 69d0803
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ fn convert_one(s: &str, pos: TextRange) -> (String, String) {
.dot_matches_new_line(true)
.build().unwrap()
.replace_all(&new_chunk, SurroundPat("", "[$2]($1)", ""));
let new_chunk = RegexBuilder::new(r#"<xref linkend="(.+?)" ?/>"#)
.multi_line(true)
.dot_matches_new_line(true)
.build().unwrap()
.replace_all(&new_chunk, SurroundPat("[](#", "$1", ")"));
let new_chunk = RegexBuilder::new(r#"<link linkend="(.+?)">(.*?)</link>"#)
.multi_line(true)
.dot_matches_new_line(true)
.build().unwrap()
.replace_all(&new_chunk, SurroundPat("", "[$2](#$1)", ""));
// let new_chunk = RegexBuilder::new(r#"<package>([^`]*?)</package>"#)
// .multi_line(true)
// .dot_matches_new_line(true)
Expand All @@ -142,6 +152,11 @@ fn convert_one(s: &str, pos: TextRange) -> (String, String) {
.dot_matches_new_line(true)
.build().unwrap()
.replace_all(&new_chunk, SurroundPat("*", "$1", "*"));
let new_chunk = RegexBuilder::new(r#"<emphasis role="string">([^*]*?)</emphasis>"#)
.multi_line(true)
.dot_matches_new_line(true)
.build().unwrap()
.replace_all(&new_chunk, SurroundPat("**", "$1", "**"));
let new_chunk = RegexBuilder::new(r#"
<citerefentry>\s*
<refentrytitle>\s*(.*?)\s*</refentrytitle>\s*
Expand Down

0 comments on commit 69d0803

Please sign in to comment.