Skip to content

Commit a7c456f

Browse files
committed
patched error in link regex
1 parent 0d2fc34 commit a7c456f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/transpiler/re.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,10 @@ pub fn bold_italicize(line: &mut String) -> String {//Option<String>
182182
///```
183183
/// use saurus::transpiler::re;
184184
/// assert_eq!(re::links(&mut "[saurus](https://github.com/paytonward6/saurus)".to_string()), r"\href{https://github.com/paytonward6/saurus}{saurus}".to_string());
185+
/// assert_eq!(re::links(&mut "[indentfirst](https://ctan.org/pkg/indentfirst) text afterwards".to_string()), r"\href{https://ctan.org/pkg/indentfirst}{indentfirst} text afterwards".to_string());
185186
///```
186187
pub fn links(line: &mut String) -> String {
187-
let re = Regex::new(r"\[([a-zA-Z:]*)\]\((https://.*)\)").unwrap();
188+
let re = Regex::new(r"\[([a-zA-Z:][^\]]*)\]\((https://[^\)\(]*)\)").unwrap();
188189
re.replace_all(line, |caps: &Captures| {
189190
format!("\\href{{{}}}{{{}}}", &caps[2], &caps[1])
190191
}).to_string()
@@ -205,9 +206,10 @@ pub fn inline_code(line: &mut String) -> String {//Option<String>
205206
///```
206207
/// use saurus::transpiler::re;
207208
/// assert_eq!(re::symbols(&mut "=>".to_string()), r"$\rightarrow$".to_string());
209+
/// assert_eq!(re::symbols(&mut "&rarr;".to_string()), r"$\rightarrow$".to_string());
208210
///```
209211
pub fn symbols(line: &mut String) -> String {//Option<String>
210-
let re = Regex::new(r"=>").unwrap();
212+
let re = Regex::new(r"=>|&rarr;").unwrap();
211213
re.replace_all(line, "$\\rightarrow$").to_string()
212214
}
213215

tests/TeX/main.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
\usepackage{listings}
66
\usepackage{hyperref}
77
\usepackage{xcolor}
8+
\usepackage{indentfirst}
89

910
\definecolor{codegreen}{rgb}{0, 0.6, 0}
1011
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
@@ -28,7 +29,7 @@
2829
}
2930
\begin{document}
3031

31-
\setcounter{secnumdepth}{0}
32+
\setcounter{secnumdepth}{0}
3233

3334

3435
\begin{quote}

0 commit comments

Comments
 (0)