fix(elements): don't export element parse function
This commit is contained in:
parent
ce8c0b1c1c
commit
b847eb9285
|
@ -12,7 +12,7 @@ pub struct Block<'a> {
|
||||||
impl Block<'_> {
|
impl Block<'_> {
|
||||||
#[inline]
|
#[inline]
|
||||||
// return (block, contents-begin, contents-end, end)
|
// 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("#+"));
|
debug_assert!(text.starts_with("#+"));
|
||||||
|
|
||||||
if text.len() <= 8 || text[2..8].to_uppercase() != "BEGIN_" {
|
if text.len() <= 8 || text[2..8].to_uppercase() != "BEGIN_" {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use bytecount::count;
|
||||||
use memchr::memchr;
|
use memchr::memchr;
|
||||||
|
|
||||||
#[inline]
|
#[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);
|
debug_assert!(text.len() >= 3);
|
||||||
|
|
||||||
let bytes = text.as_bytes();
|
let bytes = text.as_bytes();
|
||||||
|
|
|
@ -9,7 +9,7 @@ pub struct FnDef<'a> {
|
||||||
|
|
||||||
impl FnDef<'_> {
|
impl FnDef<'_> {
|
||||||
#[inline]
|
#[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:") {
|
if text.starts_with("[fn:") {
|
||||||
let (label, off) = memchr(b']', text.as_bytes())
|
let (label, off) = memchr(b']', text.as_bytes())
|
||||||
.filter(|&i| {
|
.filter(|&i| {
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub struct FnRef<'a> {
|
||||||
impl FnRef<'_> {
|
impl FnRef<'_> {
|
||||||
#[inline]
|
#[inline]
|
||||||
// return (fn_ref, offset)
|
// 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:"));
|
debug_assert!(text.starts_with("[fn:"));
|
||||||
|
|
||||||
let bytes = text.as_bytes();
|
let bytes = text.as_bytes();
|
||||||
|
|
|
@ -69,7 +69,7 @@ pub struct ListItem<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ListItem<'_> {
|
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());
|
debug_assert!(&text[0..indent].trim().is_empty());
|
||||||
let off = &text[indent..].find(' ').unwrap() + 1 + indent;
|
let off = &text[indent..].find(' ').unwrap() + 1 + indent;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ mod clock;
|
||||||
mod cookie;
|
mod cookie;
|
||||||
mod drawer;
|
mod drawer;
|
||||||
mod dyn_block;
|
mod dyn_block;
|
||||||
|
mod emphasis;
|
||||||
mod fn_def;
|
mod fn_def;
|
||||||
mod fn_ref;
|
mod fn_ref;
|
||||||
mod headline;
|
mod headline;
|
||||||
|
@ -21,7 +22,7 @@ mod snippet;
|
||||||
mod target;
|
mod target;
|
||||||
mod timestamp;
|
mod timestamp;
|
||||||
|
|
||||||
pub(crate) mod emphasis;
|
pub(crate) use emphasis::parse as parse_emphasis;
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
block::Block,
|
block::Block,
|
||||||
|
|
12
src/org.rs
12
src/org.rs
|
@ -652,7 +652,7 @@ impl<'a> Org<'a> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b'*' => emphasis::parse(text, b'*').map(|off| {
|
b'*' => parse_emphasis(text, b'*').map(|off| {
|
||||||
(
|
(
|
||||||
Element::Bold {
|
Element::Bold {
|
||||||
begin,
|
begin,
|
||||||
|
@ -663,7 +663,7 @@ impl<'a> Org<'a> {
|
||||||
off,
|
off,
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
b'+' => emphasis::parse(text, b'+').map(|off| {
|
b'+' => parse_emphasis(text, b'+').map(|off| {
|
||||||
(
|
(
|
||||||
Element::Strike {
|
Element::Strike {
|
||||||
begin,
|
begin,
|
||||||
|
@ -674,7 +674,7 @@ impl<'a> Org<'a> {
|
||||||
off,
|
off,
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
b'/' => emphasis::parse(text, b'/').map(|off| {
|
b'/' => parse_emphasis(text, b'/').map(|off| {
|
||||||
(
|
(
|
||||||
Element::Italic {
|
Element::Italic {
|
||||||
begin,
|
begin,
|
||||||
|
@ -685,7 +685,7 @@ impl<'a> Org<'a> {
|
||||||
off,
|
off,
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
b'_' => emphasis::parse(text, b'_').map(|off| {
|
b'_' => parse_emphasis(text, b'_').map(|off| {
|
||||||
(
|
(
|
||||||
Element::Underline {
|
Element::Underline {
|
||||||
begin,
|
begin,
|
||||||
|
@ -696,7 +696,7 @@ impl<'a> Org<'a> {
|
||||||
off,
|
off,
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
b'=' => emphasis::parse(text, b'=').map(|off| {
|
b'=' => parse_emphasis(text, b'=').map(|off| {
|
||||||
(
|
(
|
||||||
Element::Verbatim {
|
Element::Verbatim {
|
||||||
begin,
|
begin,
|
||||||
|
@ -706,7 +706,7 @@ impl<'a> Org<'a> {
|
||||||
off,
|
off,
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
b'~' => emphasis::parse(text, b'~').map(|off| {
|
b'~' => parse_emphasis(text, b'~').map(|off| {
|
||||||
(
|
(
|
||||||
Element::Code {
|
Element::Code {
|
||||||
begin,
|
begin,
|
||||||
|
|
Loading…
Reference in a new issue