summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml4
-rw-r--r--README.md3
-rw-r--r--src/emitter.rs10
-rw-r--r--src/lib.rs5
-rw-r--r--tests/test_spans.rs1
5 files changed, 16 insertions, 7 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 9331152..002e9f0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,6 +17,10 @@ repository = "https://git.push-f.com/html5tokenizer"
version = "0.4.0"
include = ["src/**/*", "LICENSE", "README.md"]
+[[example]]
+name = "tokenize"
+required-features = ["integration-tests"]
+
[dev-dependencies]
codespan-reporting = "0.11.1"
insta = "1.31.0"
diff --git a/README.md b/README.md
index ccb2757..ce68663 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,8 @@
`html5tokenizer` is a WHATWG-compliant HTML tokenizer
(forked from [html5gum] with added code span support).
-```rust
+<!-- TODO: update to use NaiveParser API -->
+```ignore
use std::fmt::Write;
use html5tokenizer::{DefaultEmitter, Tokenizer, Token};
diff --git a/src/emitter.rs b/src/emitter.rs
index 30e1d17..0985403 100644
--- a/src/emitter.rs
+++ b/src/emitter.rs
@@ -165,14 +165,13 @@ pub trait Emitter<O> {
fn adjusted_current_node_present_and_not_in_html_namespace(&mut self) -> bool;
}
-/// The default implementation of [`Emitter`], used to produce tokens.
-///
-/// # Warning
+/// The DefaultEmitter is not exposed in the public API because:
///
/// * Using the DefaultEmitter without calling [`Tokenizer::set_state`]
/// results in wrong state transitions:
///
-/// ```
+#[cfg_attr(not(feature = "integration-tests"), doc = "```ignore")]
+#[cfg_attr(feature = "integration-tests", doc = "```")]
/// # use html5tokenizer::{DefaultEmitter, Tokenizer, Token};
/// let emitter = DefaultEmitter::default();
/// let html = "<script><b>";
@@ -184,7 +183,8 @@ pub trait Emitter<O> {
/// * The DefaultEmitter implements [`Emitter::adjusted_current_node_present_and_not_in_html_namespace`]
/// by returning false, which results in all CDATA sections being tokenized as bogus comments.
///
-/// ```
+#[cfg_attr(not(feature = "integration-tests"), doc = "```ignore")]
+#[cfg_attr(feature = "integration-tests", doc = "```")]
/// # use html5tokenizer::{DefaultEmitter, Tokenizer, Token};
/// let emitter = DefaultEmitter::default();
/// let html = "<svg><![CDATA[I love SVG]]>";
diff --git a/src/lib.rs b/src/lib.rs
index dc012cd..c14613b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -14,13 +14,16 @@ pub mod reader;
mod tokenizer;
mod utils;
-pub use emitter::{Comment, DefaultEmitter, Doctype, Emitter, EndTag, StartTag, Token};
+pub use emitter::{Comment, Doctype, Emitter, EndTag, StartTag, Token};
pub use error::Error;
pub use tokenizer::{State, Tokenizer};
#[cfg(feature = "integration-tests")]
pub use utils::State as InternalState;
+#[cfg(feature = "integration-tests")]
+pub use emitter::DefaultEmitter;
+
/// Relative links in the README.md don't work in rustdoc, so we have to override them.
macro_rules! file_url {
($path:literal) => {
diff --git a/tests/test_spans.rs b/tests/test_spans.rs
index 9fecae8..791f1a6 100644
--- a/tests/test_spans.rs
+++ b/tests/test_spans.rs
@@ -1,3 +1,4 @@
+#![cfg(feature = "integration-tests")] // TODO: switch to NaiveParser API
use std::ops::Range;
use codespan_reporting::{