fix(elements): don't export element parse function

This commit is contained in:
PoiScript 2019-06-28 16:40:16 +08:00
parent ce8c0b1c1c
commit b847eb9285
7 changed files with 13 additions and 12 deletions

View file

@ -12,7 +12,7 @@ pub struct Block<'a> {
impl Block<'_> {
#[inline]
// return (block, contents-begin, contents-end, end)
pub fn parse(text: &str) -> Option<(Block<'_>, usize, usize, usize)> {
pub(crate) fn parse(text: &str) -> Option<(Block<'_>, usize, usize, usize)> {
debug_assert!(text.starts_with("#+"));
if text.len() <= 8 || text[2..8].to_uppercase() != "BEGIN_" {

View file

@ -2,7 +2,7 @@ use bytecount::count;
use memchr::memchr;
#[inline]
pub fn parse(text: &str, marker: u8) -> Option<usize> {
pub(crate) fn parse(text: &str, marker: u8) -> Option<usize> {
debug_assert!(text.len() >= 3);
let bytes = text.as_bytes();

View file

@ -9,7 +9,7 @@ pub struct FnDef<'a> {
impl FnDef<'_> {
#[inline]
pub fn parse(text: &str) -> Option<(FnDef<'_>, usize, usize)> {
pub(crate) fn parse(text: &str) -> Option<(FnDef<'_>, usize, usize)> {
if text.starts_with("[fn:") {
let (label, off) = memchr(b']', text.as_bytes())
.filter(|&i| {

View file

@ -13,7 +13,7 @@ pub struct FnRef<'a> {
impl FnRef<'_> {
#[inline]
// return (fn_ref, offset)
pub fn parse(text: &str) -> Option<(FnRef<'_>, usize)> {
pub(crate) fn parse(text: &str) -> Option<(FnRef<'_>, usize)> {
debug_assert!(text.starts_with("[fn:"));
let bytes = text.as_bytes();

View file

@ -69,7 +69,7 @@ pub struct ListItem<'a> {
}
impl ListItem<'_> {
pub fn parse(text: &str, indent: usize) -> (ListItem<'_>, usize, usize) {
pub(crate) fn parse(text: &str, indent: usize) -> (ListItem<'_>, usize, usize) {
debug_assert!(&text[0..indent].trim().is_empty());
let off = &text[indent..].find(' ').unwrap() + 1 + indent;

View file

@ -5,6 +5,7 @@ mod clock;
mod cookie;
mod drawer;
mod dyn_block;
mod emphasis;
mod fn_def;
mod fn_ref;
mod headline;
@ -21,7 +22,7 @@ mod snippet;
mod target;
mod timestamp;
pub(crate) mod emphasis;
pub(crate) use emphasis::parse as parse_emphasis;
pub use self::{
block::Block,

View file

@ -652,7 +652,7 @@ impl<'a> Org<'a> {
})
}
}
b'*' => emphasis::parse(text, b'*').map(|off| {
b'*' => parse_emphasis(text, b'*').map(|off| {
(
Element::Bold {
begin,
@ -663,7 +663,7 @@ impl<'a> Org<'a> {
off,
)
}),
b'+' => emphasis::parse(text, b'+').map(|off| {
b'+' => parse_emphasis(text, b'+').map(|off| {
(
Element::Strike {
begin,
@ -674,7 +674,7 @@ impl<'a> Org<'a> {
off,
)
}),
b'/' => emphasis::parse(text, b'/').map(|off| {
b'/' => parse_emphasis(text, b'/').map(|off| {
(
Element::Italic {
begin,
@ -685,7 +685,7 @@ impl<'a> Org<'a> {
off,
)
}),
b'_' => emphasis::parse(text, b'_').map(|off| {
b'_' => parse_emphasis(text, b'_').map(|off| {
(
Element::Underline {
begin,
@ -696,7 +696,7 @@ impl<'a> Org<'a> {
off,
)
}),
b'=' => emphasis::parse(text, b'=').map(|off| {
b'=' => parse_emphasis(text, b'=').map(|off| {
(
Element::Verbatim {
begin,
@ -706,7 +706,7 @@ impl<'a> Org<'a> {
off,
)
}),
b'~' => emphasis::parse(text, b'~').map(|off| {
b'~' => parse_emphasis(text, b'~').map(|off| {
(
Element::Code {
begin,