aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/construct/gfm_table.rs34
-rw-r--r--src/state.rs2
-rw-r--r--tests/gfm_table.rs19
3 files changed, 26 insertions, 29 deletions
diff --git a/src/construct/gfm_table.rs b/src/construct/gfm_table.rs
index 547358f..58b7110 100644
--- a/src/construct/gfm_table.rs
+++ b/src/construct/gfm_table.rs
@@ -661,38 +661,18 @@ pub fn body_row_start(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
Some(b'\t' | b' ') => {
- tokenizer.attempt(State::Next(StateName::GfmTableBodyRowBefore), State::Nok);
-
- State::Retry(space_or_tab_min_max(
- tokenizer,
- 0,
- if tokenizer.parse_state.options.constructs.code_indented {
- TAB_SIZE - 1
- } else {
- usize::MAX
- },
- ))
+ tokenizer.attempt(State::Next(StateName::GfmTableBodyRowBreak), State::Nok);
+ // We’re parsing a body row.
+ // If we’re here, we already attempted blank lines and indented
+ // code.
+ // So parse as much whitespace as needed:
+ State::Retry(space_or_tab_min_max(tokenizer, 0, usize::MAX))
}
- _ => State::Retry(StateName::GfmTableBodyRowBefore),
+ _ => State::Retry(StateName::GfmTableBodyRowBreak),
}
}
}
-/// Before table body row, after optional whitespace.
-///
-/// ```markdown
-/// | | a |
-/// | | - |
-/// > | | b |
-/// ^
-/// ```
-pub fn body_row_before(tokenizer: &mut Tokenizer) -> State {
- match tokenizer.current {
- Some(b'\t' | b' ') => State::Nok,
- _ => State::Retry(StateName::GfmTableBodyRowBreak),
- }
-}
-
/// At break in table body row.
///
/// ```markdown
diff --git a/src/state.rs b/src/state.rs
index 8dd2ae7..b013c39 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -212,7 +212,6 @@ pub enum Name {
GfmTableHeadDelimiterCellAfter,
GfmTableHeadDelimiterNok,
- GfmTableBodyRowBefore,
GfmTableBodyRowStart,
GfmTableBodyRowBreak,
GfmTableBodyRowData,
@@ -662,7 +661,6 @@ pub fn call(tokenizer: &mut Tokenizer, name: Name) -> State {
}
Name::GfmTableHeadDelimiterCellAfter => construct::gfm_table::head_delimiter_cell_after,
Name::GfmTableHeadDelimiterNok => construct::gfm_table::head_delimiter_nok,
- Name::GfmTableBodyRowBefore => construct::gfm_table::body_row_before,
Name::GfmTableBodyRowStart => construct::gfm_table::body_row_start,
Name::GfmTableBodyRowBreak => construct::gfm_table::body_row_break,
Name::GfmTableBodyRowData => construct::gfm_table::body_row_data,
diff --git a/tests/gfm_table.rs b/tests/gfm_table.rs
index d824355..54e0ace 100644
--- a/tests/gfm_table.rs
+++ b/tests/gfm_table.rs
@@ -379,6 +379,25 @@ fn gfm_table() -> Result<(), String> {
);
assert_eq!(
+ to_html_with_options(" | a |\n\t| - |\n | b |", &Options {
+ parse: ParseOptions {
+ constructs: Constructs {
+ code_indented: false,
+ ..Constructs::gfm()
+ },
+ ..ParseOptions::default()
+ },
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ }
+ })?,
+ "<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>b</td>\n</tr>\n</tbody>\n</table>",
+ "should support indented rows if code (indented) is off"
+ );
+
+ assert_eq!(
to_html_with_options(
r###"# Align