All Projects → f34nk → modest_ex

f34nk / modest_ex

Licence: LGPL-2.1 License
Elixir library to do pipeable transformations on html strings (with CSS selectors)

Programming Languages

c
50402 projects - #5 most used programming language
elixir
2628 projects
CMake
9771 projects
shell
77523 projects

Projects that are alternatives of or similar to modest ex

Apifier
Apifier is a very simple HTML parser written in Python based on CSS selectors
Stars: ✭ 5 (-83.87%)
Mutual labels:  css-selector, html-parser
Modest
Modest is a fast HTML renderer implemented as a pure C99 library with no outside dependencies.
Stars: ✭ 572 (+1745.16%)
Mutual labels:  css-selector, html-parser
React Native Htmlview
A React Native component which renders HTML content as native views
Stars: ✭ 2,546 (+8112.9%)
Mutual labels:  html-parser, html-renderer
Floki
Floki is a simple HTML parser that enables search for nodes using CSS selectors.
Stars: ✭ 1,642 (+5196.77%)
Mutual labels:  css-selector, html-parser
Aris
Aris - A fast and powerful tool to write HTML in JS easily. Includes syntax highlighting, templates, SVG, CSS autofixing, debugger support and more...
Stars: ✭ 61 (+96.77%)
Mutual labels:  html-parser
html2data
Library and cli for extracting data from HTML via CSS selectors
Stars: ✭ 62 (+100%)
Mutual labels:  css-selector
visdom
A library use jQuery like API for html parsing & node selecting & node mutation, suitable for web scraping and html confusion.
Stars: ✭ 80 (+158.06%)
Mutual labels:  css-selector
bkit
build a messenger bot using HTML
Stars: ✭ 36 (+16.13%)
Mutual labels:  html-parser
selective
Statically find HTML anti patterns using CSS Selectors
Stars: ✭ 15 (-51.61%)
Mutual labels:  css-selector
ElementFinder
Fetch data from HTML and XML via xpath/css and prepare it with regexp
Stars: ✭ 29 (-6.45%)
Mutual labels:  css-selector
HtmlMonkey
Lightweight HTML/XML parser written in C#.
Stars: ✭ 37 (+19.35%)
Mutual labels:  html-parser
CustomWebCheckbox
An example of a make checkbox design on the web.
Stars: ✭ 12 (-61.29%)
Mutual labels:  css-selector
Landing-Page-Animation
Landing page animation made using CSS
Stars: ✭ 45 (+45.16%)
Mutual labels:  css-selector
html-parser
Simple HTML to JSON parser use Regexp and String.indexOf
Stars: ✭ 34 (+9.68%)
Mutual labels:  html-parser
ioBroker.parser
Parse web-site or file and extract data from it.
Stars: ✭ 14 (-54.84%)
Mutual labels:  html-parser
DHTMLParser
D HTML Parser, similar to python BeautifulSoup
Stars: ✭ 17 (-45.16%)
Mutual labels:  html-parser
CDom
Simple HTML/XML/BBCode DOM component for PHP.
Stars: ✭ 26 (-16.13%)
Mutual labels:  css-selector
Dom
Modern DOM API.
Stars: ✭ 88 (+183.87%)
Mutual labels:  css-selector
htmlparser
delphi html parser(代码是改自原wr960204的HtmlParser)
Stars: ✭ 65 (+109.68%)
Mutual labels:  html-parser
GQ
CSS Selector Engine for Gumbo Parser
Stars: ✭ 25 (-19.35%)
Mutual labels:  css-selector

This project is not maintained anymore.

Build status ModestEx version Hex.pm

humble by Eliricon from the Noun Project

ModestEx

A library to do pipeable transformations on html strings with CSS selectors, e.g. find(), prepend(), append(), replace() etc.

Elixir/Erlang bindings for lexborisov's Modest

Modest is a fast HTML renderer implemented as a pure C99 library with no outside dependencies.

  • Modest
    • HTML5 parsing library in pure C99
    • fully conformant with the HTML5 spec

All Modest-related features are implemented in C using my wrapper library modest_html.

The binding is implemented as a C-Node following the excellent example in Overbryd's package nodex. If you want to learn how to set up bindings to C/C++, you should definitely check it out.

  • nodex
    • distributed Elixir
    • save binding with C-Nodes

C-Nodes are external os-processes that communicate with the Erlang VM through erlang messaging. That way you can implement native code and call into it from Elixir in a safe predictable way. The Erlang VM stays unaffected by crashes of the external process.

For news and updates please check out the forum discussion.

Example

Total 16 features implemented. See complete feature list.

Build transformation pipelines...

test "build up a complete DOM" do
  result = ""
  |> ModestEx.serialize()
  |> ModestEx.append("body", "<div>")
  |> ModestEx.set_attribute("div", "class", "col-md-12")
  |> ModestEx.append("div", "<div>")
  |> ModestEx.set_attribute("div.col-md-12 div", "class", "col-md-6")
  |> ModestEx.append("div.col-md-12 div", "<a></a>")
  |> ModestEx.set_text("a", "Hello")

  copy = ModestEx.find(result, "div.col-md-12 div")
  |> ModestEx.set_text("a", "World")
  
  result = ModestEx.insert_after(result, "div.col-md-12 div", copy)
  |> ModestEx.set_attribute("div.col-md-6:first-of-type a", "href", "https://elixir-lang.org")
  |> ModestEx.set_attribute("div.col-md-6:last-of-type a", "href", "https://google.de")
  
  assert result == "<div class=\"col-md-12\"><div class=\"col-md-6\"><a href=\"https://elixir-lang.org\">Hello</a></div><div class=\"col-md-6\"><a href=\"https://google.de\">World</a></div></div>"
end

Supported CSS Selectors

All common CSS Selectors are supported. Total 38 selector patterns implemented. See complete list of supported CSS selectors.

Installation

Available on hex.

def deps do
  [
    {:modest_ex, "~> 1.0.4"}
  ]
end

Target dependencies

cmake 3.x
erlang-dev
erlang-xmerl
erlang-parsetools

Compile and test

mix deps.get
mix compile
mix test

Cloning

git clone [email protected]:f34nk/modest_ex.git
cd modest_ex

All binding targets are added as submodules in the target/ folder.

git submodule update --init --recursive --remote
mix deps.get
mix compile
mix test
mix test.target

Cleanup

mix clean

Roadmap

See CHANGELOG.

  • Bindings
    • Call as C-Node
    • Call as dirty-nif
  • Tests
    • Call as C-Node
    • Call as dirty-nif
    • Target tests
    • Feature tests
    • Package test
  • Features
    • Find nodes using a CSS selector
    • Serialize any string with valid or broken html
    • Get attribute with optional CSS selector
    • Set attribute with optional CSS selector
    • Get text with optional CSS selector
    • Set text with optional CSS selector
    • Remove a node from html
    • Append node to another node
    • Prepend node to another node
    • Insert node before another node
    • Insert node after another node
    • Replace node with another node
    • Slice html to a subset of nodes
    • Get position of node in relation to its parent
    • Wrap node with another node
    • Pretty print html
    • Compare two html strings (see here)
    • Transform html string by list of actions
  • Custom CSS selector for pseudo class :contains(text) implemented in Modest
  • Scope flag to control serialization
  • List of supported CSS Selectors
  • Documentation
  • Publish as hex package

License

ModestEx is under LGPL license. Check the LICENSE file for more details.

Icon Credit

humble by Eliricon from the Noun Project

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].