zola/components/markdown/tests/summary.rs

48 lines
787 B
Rust
Raw Normal View History

Shortcodes (#1640) * Next version * Added tests for shortcode insertion * Added TOC tests * Added test for #1475 and #1355 * Basic internal / external links tests * Added integration test * Added pseudocode and started on logos * Logos parsing for shortcodes * Fixed string literal parsing Moved string literal parsing to a new lexer in order to have greater control of control characters which are parsed. This fixes the bug that was present in the `string_from_quoted` function and also moves the `QuoteType` to be in the `ArgValueToken`. * Moved string literal logic to seperate module * Added square bracket notation for variables * Error handling rewritten Remove the Result from the `fetch_shortcodes` function. Added proper messages within the internal parsing. * Reorganized and documented the shortcode submodule * Added all logic for ShortcodeContext spans * Added working insertion code for MD files * Made functions generic over Markdown or HTML * Add check for embedding bodies * Structure of main function clear * Added test for `new_with_transforms` function * It runs! * Added the code for handling p-ed html shortcodes * Removed placeholders in markdown function * Adjusted integration tests * fetch_shortcodes now also returns a string * Start of HTML insertion * Kinda working everything * Loading of shortcodes and builtins * Fix tests * Some missed fixes * Tweaks + fmt * Remove string literal handling * Fix benches * Grab shortcode def only once per site * Fix benches * Rewrite of parser * Fix tests * Add test for #1655 * Re-enable integration test * Add test for #1601 * Add test for #1600 * Add test for #1500 * Add test for #1320 * Fix test on windows? Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>
2021-11-19 19:31:42 +00:00
mod common;
2022-02-25 16:13:29 +00:00
fn get_summary(content: &str) -> String {
let rendered = common::render(content).unwrap();
assert!(rendered.summary_len.is_some());
let summary_len = rendered.summary_len.unwrap();
rendered.body[..summary_len].to_owned()
Shortcodes (#1640) * Next version * Added tests for shortcode insertion * Added TOC tests * Added test for #1475 and #1355 * Basic internal / external links tests * Added integration test * Added pseudocode and started on logos * Logos parsing for shortcodes * Fixed string literal parsing Moved string literal parsing to a new lexer in order to have greater control of control characters which are parsed. This fixes the bug that was present in the `string_from_quoted` function and also moves the `QuoteType` to be in the `ArgValueToken`. * Moved string literal logic to seperate module * Added square bracket notation for variables * Error handling rewritten Remove the Result from the `fetch_shortcodes` function. Added proper messages within the internal parsing. * Reorganized and documented the shortcode submodule * Added all logic for ShortcodeContext spans * Added working insertion code for MD files * Made functions generic over Markdown or HTML * Add check for embedding bodies * Structure of main function clear * Added test for `new_with_transforms` function * It runs! * Added the code for handling p-ed html shortcodes * Removed placeholders in markdown function * Adjusted integration tests * fetch_shortcodes now also returns a string * Start of HTML insertion * Kinda working everything * Loading of shortcodes and builtins * Fix tests * Some missed fixes * Tweaks + fmt * Remove string literal handling * Fix benches * Grab shortcode def only once per site * Fix benches * Rewrite of parser * Fix tests * Add test for #1655 * Re-enable integration test * Add test for #1601 * Add test for #1600 * Add test for #1500 * Add test for #1320 * Fix test on windows? Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>
2021-11-19 19:31:42 +00:00
}
#[test]
fn basic_summary() {
2022-02-25 16:13:29 +00:00
let body = get_summary(
r#"
Hello world!
Shortcodes (#1640) * Next version * Added tests for shortcode insertion * Added TOC tests * Added test for #1475 and #1355 * Basic internal / external links tests * Added integration test * Added pseudocode and started on logos * Logos parsing for shortcodes * Fixed string literal parsing Moved string literal parsing to a new lexer in order to have greater control of control characters which are parsed. This fixes the bug that was present in the `string_from_quoted` function and also moves the `QuoteType` to be in the `ArgValueToken`. * Moved string literal logic to seperate module * Added square bracket notation for variables * Error handling rewritten Remove the Result from the `fetch_shortcodes` function. Added proper messages within the internal parsing. * Reorganized and documented the shortcode submodule * Added all logic for ShortcodeContext spans * Added working insertion code for MD files * Made functions generic over Markdown or HTML * Add check for embedding bodies * Structure of main function clear * Added test for `new_with_transforms` function * It runs! * Added the code for handling p-ed html shortcodes * Removed placeholders in markdown function * Adjusted integration tests * fetch_shortcodes now also returns a string * Start of HTML insertion * Kinda working everything * Loading of shortcodes and builtins * Fix tests * Some missed fixes * Tweaks + fmt * Remove string literal handling * Fix benches * Grab shortcode def only once per site * Fix benches * Rewrite of parser * Fix tests * Add test for #1655 * Re-enable integration test * Add test for #1601 * Add test for #1600 * Add test for #1500 * Add test for #1320 * Fix test on windows? Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>
2021-11-19 19:31:42 +00:00
2022-02-25 16:13:29 +00:00
# Introduction
Shortcodes (#1640) * Next version * Added tests for shortcode insertion * Added TOC tests * Added test for #1475 and #1355 * Basic internal / external links tests * Added integration test * Added pseudocode and started on logos * Logos parsing for shortcodes * Fixed string literal parsing Moved string literal parsing to a new lexer in order to have greater control of control characters which are parsed. This fixes the bug that was present in the `string_from_quoted` function and also moves the `QuoteType` to be in the `ArgValueToken`. * Moved string literal logic to seperate module * Added square bracket notation for variables * Error handling rewritten Remove the Result from the `fetch_shortcodes` function. Added proper messages within the internal parsing. * Reorganized and documented the shortcode submodule * Added all logic for ShortcodeContext spans * Added working insertion code for MD files * Made functions generic over Markdown or HTML * Add check for embedding bodies * Structure of main function clear * Added test for `new_with_transforms` function * It runs! * Added the code for handling p-ed html shortcodes * Removed placeholders in markdown function * Adjusted integration tests * fetch_shortcodes now also returns a string * Start of HTML insertion * Kinda working everything * Loading of shortcodes and builtins * Fix tests * Some missed fixes * Tweaks + fmt * Remove string literal handling * Fix benches * Grab shortcode def only once per site * Fix benches * Rewrite of parser * Fix tests * Add test for #1655 * Re-enable integration test * Add test for #1601 * Add test for #1600 * Add test for #1500 * Add test for #1320 * Fix test on windows? Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>
2021-11-19 19:31:42 +00:00
2022-02-25 16:13:29 +00:00
- first
- second
Shortcodes (#1640) * Next version * Added tests for shortcode insertion * Added TOC tests * Added test for #1475 and #1355 * Basic internal / external links tests * Added integration test * Added pseudocode and started on logos * Logos parsing for shortcodes * Fixed string literal parsing Moved string literal parsing to a new lexer in order to have greater control of control characters which are parsed. This fixes the bug that was present in the `string_from_quoted` function and also moves the `QuoteType` to be in the `ArgValueToken`. * Moved string literal logic to seperate module * Added square bracket notation for variables * Error handling rewritten Remove the Result from the `fetch_shortcodes` function. Added proper messages within the internal parsing. * Reorganized and documented the shortcode submodule * Added all logic for ShortcodeContext spans * Added working insertion code for MD files * Made functions generic over Markdown or HTML * Add check for embedding bodies * Structure of main function clear * Added test for `new_with_transforms` function * It runs! * Added the code for handling p-ed html shortcodes * Removed placeholders in markdown function * Adjusted integration tests * fetch_shortcodes now also returns a string * Start of HTML insertion * Kinda working everything * Loading of shortcodes and builtins * Fix tests * Some missed fixes * Tweaks + fmt * Remove string literal handling * Fix benches * Grab shortcode def only once per site * Fix benches * Rewrite of parser * Fix tests * Add test for #1655 * Re-enable integration test * Add test for #1601 * Add test for #1600 * Add test for #1500 * Add test for #1320 * Fix test on windows? Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>
2021-11-19 19:31:42 +00:00
2022-02-25 16:13:29 +00:00
<!-- more -->
And some content after
"#,
Shortcodes (#1640) * Next version * Added tests for shortcode insertion * Added TOC tests * Added test for #1475 and #1355 * Basic internal / external links tests * Added integration test * Added pseudocode and started on logos * Logos parsing for shortcodes * Fixed string literal parsing Moved string literal parsing to a new lexer in order to have greater control of control characters which are parsed. This fixes the bug that was present in the `string_from_quoted` function and also moves the `QuoteType` to be in the `ArgValueToken`. * Moved string literal logic to seperate module * Added square bracket notation for variables * Error handling rewritten Remove the Result from the `fetch_shortcodes` function. Added proper messages within the internal parsing. * Reorganized and documented the shortcode submodule * Added all logic for ShortcodeContext spans * Added working insertion code for MD files * Made functions generic over Markdown or HTML * Add check for embedding bodies * Structure of main function clear * Added test for `new_with_transforms` function * It runs! * Added the code for handling p-ed html shortcodes * Removed placeholders in markdown function * Adjusted integration tests * fetch_shortcodes now also returns a string * Start of HTML insertion * Kinda working everything * Loading of shortcodes and builtins * Fix tests * Some missed fixes * Tweaks + fmt * Remove string literal handling * Fix benches * Grab shortcode def only once per site * Fix benches * Rewrite of parser * Fix tests * Add test for #1655 * Re-enable integration test * Add test for #1601 * Add test for #1600 * Add test for #1500 * Add test for #1320 * Fix test on windows? Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>
2021-11-19 19:31:42 +00:00
);
2022-02-25 16:13:29 +00:00
insta::assert_snapshot!(body);
Shortcodes (#1640) * Next version * Added tests for shortcode insertion * Added TOC tests * Added test for #1475 and #1355 * Basic internal / external links tests * Added integration test * Added pseudocode and started on logos * Logos parsing for shortcodes * Fixed string literal parsing Moved string literal parsing to a new lexer in order to have greater control of control characters which are parsed. This fixes the bug that was present in the `string_from_quoted` function and also moves the `QuoteType` to be in the `ArgValueToken`. * Moved string literal logic to seperate module * Added square bracket notation for variables * Error handling rewritten Remove the Result from the `fetch_shortcodes` function. Added proper messages within the internal parsing. * Reorganized and documented the shortcode submodule * Added all logic for ShortcodeContext spans * Added working insertion code for MD files * Made functions generic over Markdown or HTML * Add check for embedding bodies * Structure of main function clear * Added test for `new_with_transforms` function * It runs! * Added the code for handling p-ed html shortcodes * Removed placeholders in markdown function * Adjusted integration tests * fetch_shortcodes now also returns a string * Start of HTML insertion * Kinda working everything * Loading of shortcodes and builtins * Fix tests * Some missed fixes * Tweaks + fmt * Remove string literal handling * Fix benches * Grab shortcode def only once per site * Fix benches * Rewrite of parser * Fix tests * Add test for #1655 * Re-enable integration test * Add test for #1601 * Add test for #1600 * Add test for #1500 * Add test for #1320 * Fix test on windows? Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>
2021-11-19 19:31:42 +00:00
}
2022-02-25 16:13:29 +00:00
// https://zola.discourse.group/t/zola-12-issue-with-continue-reading/590/7
Shortcodes (#1640) * Next version * Added tests for shortcode insertion * Added TOC tests * Added test for #1475 and #1355 * Basic internal / external links tests * Added integration test * Added pseudocode and started on logos * Logos parsing for shortcodes * Fixed string literal parsing Moved string literal parsing to a new lexer in order to have greater control of control characters which are parsed. This fixes the bug that was present in the `string_from_quoted` function and also moves the `QuoteType` to be in the `ArgValueToken`. * Moved string literal logic to seperate module * Added square bracket notation for variables * Error handling rewritten Remove the Result from the `fetch_shortcodes` function. Added proper messages within the internal parsing. * Reorganized and documented the shortcode submodule * Added all logic for ShortcodeContext spans * Added working insertion code for MD files * Made functions generic over Markdown or HTML * Add check for embedding bodies * Structure of main function clear * Added test for `new_with_transforms` function * It runs! * Added the code for handling p-ed html shortcodes * Removed placeholders in markdown function * Adjusted integration tests * fetch_shortcodes now also returns a string * Start of HTML insertion * Kinda working everything * Loading of shortcodes and builtins * Fix tests * Some missed fixes * Tweaks + fmt * Remove string literal handling * Fix benches * Grab shortcode def only once per site * Fix benches * Rewrite of parser * Fix tests * Add test for #1655 * Re-enable integration test * Add test for #1601 * Add test for #1600 * Add test for #1500 * Add test for #1320 * Fix test on windows? Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>
2021-11-19 19:31:42 +00:00
#[test]
2022-02-25 16:13:29 +00:00
fn summary_with_shortcodes() {
let body = get_summary(
r#"
{{ a() }} {{ a() }}
{% render_md() %}
# Hello world
{% end %}
```
some code;
```
<!-- more -->
And some content after
"#,
Shortcodes (#1640) * Next version * Added tests for shortcode insertion * Added TOC tests * Added test for #1475 and #1355 * Basic internal / external links tests * Added integration test * Added pseudocode and started on logos * Logos parsing for shortcodes * Fixed string literal parsing Moved string literal parsing to a new lexer in order to have greater control of control characters which are parsed. This fixes the bug that was present in the `string_from_quoted` function and also moves the `QuoteType` to be in the `ArgValueToken`. * Moved string literal logic to seperate module * Added square bracket notation for variables * Error handling rewritten Remove the Result from the `fetch_shortcodes` function. Added proper messages within the internal parsing. * Reorganized and documented the shortcode submodule * Added all logic for ShortcodeContext spans * Added working insertion code for MD files * Made functions generic over Markdown or HTML * Add check for embedding bodies * Structure of main function clear * Added test for `new_with_transforms` function * It runs! * Added the code for handling p-ed html shortcodes * Removed placeholders in markdown function * Adjusted integration tests * fetch_shortcodes now also returns a string * Start of HTML insertion * Kinda working everything * Loading of shortcodes and builtins * Fix tests * Some missed fixes * Tweaks + fmt * Remove string literal handling * Fix benches * Grab shortcode def only once per site * Fix benches * Rewrite of parser * Fix tests * Add test for #1655 * Re-enable integration test * Add test for #1601 * Add test for #1600 * Add test for #1500 * Add test for #1320 * Fix test on windows? Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>
2021-11-19 19:31:42 +00:00
);
2022-02-25 16:13:29 +00:00
insta::assert_snapshot!(body);
Shortcodes (#1640) * Next version * Added tests for shortcode insertion * Added TOC tests * Added test for #1475 and #1355 * Basic internal / external links tests * Added integration test * Added pseudocode and started on logos * Logos parsing for shortcodes * Fixed string literal parsing Moved string literal parsing to a new lexer in order to have greater control of control characters which are parsed. This fixes the bug that was present in the `string_from_quoted` function and also moves the `QuoteType` to be in the `ArgValueToken`. * Moved string literal logic to seperate module * Added square bracket notation for variables * Error handling rewritten Remove the Result from the `fetch_shortcodes` function. Added proper messages within the internal parsing. * Reorganized and documented the shortcode submodule * Added all logic for ShortcodeContext spans * Added working insertion code for MD files * Made functions generic over Markdown or HTML * Add check for embedding bodies * Structure of main function clear * Added test for `new_with_transforms` function * It runs! * Added the code for handling p-ed html shortcodes * Removed placeholders in markdown function * Adjusted integration tests * fetch_shortcodes now also returns a string * Start of HTML insertion * Kinda working everything * Loading of shortcodes and builtins * Fix tests * Some missed fixes * Tweaks + fmt * Remove string literal handling * Fix benches * Grab shortcode def only once per site * Fix benches * Rewrite of parser * Fix tests * Add test for #1655 * Re-enable integration test * Add test for #1601 * Add test for #1600 * Add test for #1500 * Add test for #1320 * Fix test on windows? Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>
2021-11-19 19:31:42 +00:00
}