Fix a bunch more emphasis tests
@@ -688,21 +688,17 @@ fn is_left_flanking(bytes: &[u8], run_len: usize, ix: usize) -> bool {
if is_ascii_whitespace(next_byte) {
return false;
}
+ if ix == 0 {
+ return true;
+ }
let delim = bytes[ix];
if delim == b'*' {
if !is_ascii_punctuation(next_byte) {
return true;
}
- if ix == 0 {
- return false;
- }
} else {
// delim must be b'_'
if !is_ascii_punctuation(next_byte) {
- if ix == 0 {
- return true;
- }
-
// this mess is to prevent intra word emphasis with _
// TODO: function name no longer representative
let prev_byte = bytes[ix - 1];
@@ -727,6 +723,8 @@ fn is_right_flanking(bytes: &[u8], run_len: usize, ix: usize) -> bool {
// FIXME: we really should get the prev char!
let prev_byte = bytes[ix - 1];
+ // TODO: prevent intra-word emphasis with _
+
if is_ascii_whitespace(prev_byte) {
return false;
}
@@ -800,6 +798,8 @@ fn parse_line(tree: &mut Tree<Item>, s: &str, mut ix: usize) -> (usize, Option<I
let left_flanking = is_left_flanking(bytes, count, ix);
let right_flanking = is_right_flanking(bytes, count, ix);
+ eprintln!("left: {:?}, right: {:?}", left_flanking, right_flanking);
+
if left_flanking || right_flanking {
tree.append_text(begin_text, ix);
for i in 0..count {
