jenkins-bot has submitted this change and it was merged.

Change subject: Add docs
......................................................................


Add docs

Change-Id: Ia3ce65a7f227ccba6ec75bcf6431c129efb8d695
---
M README.md
1 file changed, 32 insertions(+), 1 deletion(-)

Approvals:
  BryanDavis: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/README.md b/README.md
index 499e5b4..f6e2e1b 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,36 @@
-TODO Write stuff here
+HtmlFormatter is a library spun off MediaWiki that allows you to load HTML 
into DomDocument, perform manipulations on it, and then return a HTML string.
 
+Usage
+-----
+
+```
+use HtmlFormatter\HtmlFormatter;
+// Load HTML that already has doctype and stuff
+$formatter = new HtmlFormatter( $html );
+
+// ...or one that doesn't have it
+$formatter = new HtmlFormatter( HtmlFormatter::wrapHTML( $html ) );
+
+// Add rules to remove some stuff
+$formatter->remove( 'img' );
+$formatter->remove( [ '.some_css_class', '#some_id', 'div.some_other_class' ] 
);
+// Only the above syntax is supported, not full CSS/jQuery selectors
+
+// These tags get replaced with their inner HTML,
+// e.g. <tag>foo</tag> --> foo
+// Only tag names are supported here
+$formatter->flatten( 'span' );
+$formatter->flatten( [ 'code', 'pre' ] );
+
+// Actually perform the removals
+$formatter->filterContent();
+
+// Direct DomDocument manipulations are possible
+$formatter->getDoc()->createElement( 'p', 'Appended paragraph' );
+
+// Get resulting HTML
+$processedHtml = $formatter->getText();
+```
 
 License
 -------

-- 
To view, visit https://gerrit.wikimedia.org/r/282083
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia3ce65a7f227ccba6ec75bcf6431c129efb8d695
Gerrit-PatchSet: 2
Gerrit-Project: HtmlFormatter
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to