Skip to content

Commit

Permalink
attempt to address @bryon first comments
Browse files Browse the repository at this point in the history
  • Loading branch information
SichangHe committed May 30, 2024
1 parent 542bc1f commit bebff1e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ use pulldown_cmark::{Alignment as TableAlignment, Event, HeadingLevel, LinkType,
mod source_range;
mod text_modifications;

pub use source_range::*;
pub use source_range::{
cmark_resume_with_source_range, cmark_resume_with_source_range_and_options, cmark_with_source_range,
cmark_with_source_range_and_options,
};
use text_modifications::*;

/// Similar to [Pulldown-Cmark-Alignment][Alignment], but with required
Expand Down Expand Up @@ -69,7 +72,7 @@ pub struct State<'a> {
pub current_shortcut_text: Option<String>,
/// A list of shortcuts seen so far for later emission
pub shortcuts: Vec<(String, String, String)>,
/// Index of the end of the last event.
/// Index of the end of the range corresponding to the last event.
pub last_event_end_index: usize,
}

Expand Down
13 changes: 7 additions & 6 deletions src/source_range.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
use super::*;
use super::{cmark_resume_one_event, fmt, Borrow, Event, Options, Range, State};

/// Serialize a stream of [pulldown-cmark-Events][Event] each with source string into a string-backed buffer.
/// Serialize a stream of [pulldown-cmark-Events][Event] while preserving the escape characters in `source`.
/// Each input [Event] is accompanied by an optional [Range] that maps it back to the `source` string.
///
/// Different from [`cmark_resume_with_options`], which always escape Markdown special characters like `#` or `[`,
/// this function preserves special character escapes.
/// That is, it only escapes a special character if it is escaped in the source.
/// this function only escapes a special character if it is escaped in `source`.
///
/// 1. **source**
/// * Markdown source.
/// * Markdown source from which `event_and_ranges` are created.
/// 1. **event_and_ranges**
/// * An iterator over [`Event`]-range pairs, for example as returned by [`pulldown_cmark::OffsetIter`].
/// Must match what's provided in `source`.
/// 1. **formatter**
/// * A format writer, can be a `String`.
/// 1. **state**
/// * The optional initial state of the serialization.
/// * The optional initial state of the serialization, useful when the operation should be resumed.
/// 1. **options**
/// * Customize the appearance of the serialization. All otherwise magic values are contained
/// here.
Expand Down
2 changes: 1 addition & 1 deletion src/text_modifications.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::*;
use super::{fmt, Cow, Options, State};

pub fn padding<F>(f: &mut F, p: &[Cow<'_, str>]) -> fmt::Result
where
Expand Down

0 comments on commit bebff1e

Please sign in to comment.