Skip to content

Commit c735c1d

Browse files
authored
Merge pull request #52 from mischov/chore/update-dependencies
Update Rust and Elixir dependencies and change compatibility
2 parents 4b2d833 + 0435b67 commit c735c1d

File tree

9 files changed

+77
-64
lines changed

9 files changed

+77
-64
lines changed

.github/workflows/tests.yml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ jobs:
1212
- name: Set up Elixir
1313
uses: erlef/setup-beam@v1
1414
with:
15-
otp-version: '24.0'
16-
elixir-version: '1.12.0'
15+
otp-version: '25.0'
16+
elixir-version: '1.14.0'
1717

1818
- name: Check formatting
1919
run: mix format --check-formatted
2020

2121
test-elixir:
2222
name: Test with OTP ${{ matrix.otp }} and Elixir ${{ matrix.elixir }}
23-
runs-on: ubuntu-latest
23+
# TODO change this to ubuntu-latest after OTP 23 is deprecated, see
24+
# https://github.com/erlef/setup-beam#compatibility-between-operating-system-and-erlangotp
25+
# for compatibility
26+
runs-on: ubuntu-20.04
2427

2528
env:
2629
MIX_ENV: test
@@ -29,31 +32,24 @@ jobs:
2932
fail-fast: false
3033
matrix:
3134
include:
32-
- otp: '21.0'
33-
elixir: '1.7.0'
34-
- otp: '21.0'
35-
elixir: '1.11.0'
36-
- otp: '22.0'
37-
elixir: '1.7.0'
38-
- otp: '22.0'
39-
elixir: '1.11.0'
40-
- otp: '23.0'
41-
elixir: '1.10.3'
4235
- otp: '23.0'
4336
elixir: '1.12.0'
44-
- otp: '24.0'
45-
elixir: '1.11.4'
37+
- otp: '23.0'
38+
elixir: '1.14.3'
4639
- otp: '24.0'
4740
elixir: '1.12.0'
41+
- otp: '24.0'
42+
elixir: '1.14.3'
43+
- otp: '25.0'
44+
elixir: '1.13.4'
45+
- otp: '25.0'
46+
elixir: '1.14.3'
4847

4948
steps:
50-
- uses: actions/checkout@v2
49+
- uses: actions/checkout@v3
5150

5251
- name: Set up Rust
53-
uses: actions-rs/toolchain@v1
54-
with:
55-
toolchain: stable
56-
override: true
52+
uses: dtolnay/rust-toolchain@stable
5753

5854
- name: Set up Elixir
5955
uses: erlef/setup-beam@v1

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
## Unreleased
44

5+
### Compatibility
6+
7+
* No longer support Elixir versions under 1.12 or Erlang/OTP versions under 23.0
8+
* Support Elixir 1.13 and 1.14 and Erlang/OTP 25.0
9+
* Use Rustler v0.27
10+
11+
### Enhancements
12+
13+
* Use Rust 2018 edition
14+
* Update to latest versions of `html5ever`, `xml5ever`, and `rustler`
15+
16+
### Fixes
17+
18+
* Fix Rust formatting and clippy issues
19+
520
## v0.13.1 (2021-10-20)
621

722
### Compatibility

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Originally a fork of Hansihe's [html5ever_elixir](https://github.com/hansihe/htm
77

88
## Compatibility
99

10-
Meeseeks_Html5ever requires a minimum combination of Elixir 1.7.0 and Erlang/OTP 21.0, and is tested with a maximum combination of Elixir 1.12.0 and Erlang/OTP 24.0.
10+
Meeseeks_Html5ever requires a minimum combination of Elixir 1.12.0 and Erlang/OTP 23.0, and is tested with a maximum combination of Elixir 1.14.0 and Erlang/OTP 25.0.
1111

1212
## Dependencies
1313

config/config.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use Mix.Config
1+
import Config
22

33
config :meeseeks_html5ever, MeeseeksHtml5ever.Native,
44
path: "native/meeseeks_html5ever_nif",

mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defmodule MeeseeksHtml5ever.Mixfile do
99
name: "MeeseeksHtml5ever",
1010
version: @version,
1111
description: description(),
12-
elixir: "~> 1.7",
12+
elixir: "~> 1.12",
1313
deps: deps(),
1414
package: package(),
1515
source_url: "https://github.com/mischov/meeseeks_html5ever",
@@ -26,7 +26,7 @@ defmodule MeeseeksHtml5ever.Mixfile do
2626

2727
defp deps do
2828
[
29-
{:rustler, "~> 0.22.0"},
29+
{:rustler, "~> 0.27.0"},
3030

3131
# docs
3232
{:ex_doc, "~> 0.21.0", only: :docs, runtime: false}

mix.lock

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
"earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"},
44
"ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"},
55
"hoedown": {:git, "https://github.com/hoedown/hoedown.git", "980b9c549b4348d50b683ecee6abee470b98acda", []},
6+
"jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"},
67
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
78
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
89
"markdown": {:git, "https://github.com/devinus/markdown.git", "d065dbcc4e242a85ca2516fdadd0082712871fd8", []},
910
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
10-
"rustler": {:hex, :rustler, "0.22.0", "e2930f9d6933e910f87526bb0a7f904e32b62a7e838a3ca4a884ee7fdfb957ed", [:mix], [{:toml, "~> 0.5.2", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "01f5989dd511ebec09be481e07d3c59773d5373c5061e09d3ebc3ef61811b49d"},
11-
"toml": {:hex, :toml, "0.5.2", "e471388a8726d1ce51a6b32f864b8228a1eb8edc907a0edf2bb50eab9321b526", [:mix], [], "hexpm", "f1e3dabef71fb510d015fad18c0e05e7c57281001141504c6b69d94e99750a07"},
11+
"rustler": {:hex, :rustler, "0.27.0", "53ffe86586fd1a2ea60ad07f1506962914eb669dba26c23010cf672662ec8d64", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:toml, "~> 0.6", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "d7f5ccaec6e7a96f700330898ff2e9d48818e40789fd2951ba41ecf457986e92"},
12+
"toml": {:hex, :toml, "0.7.0", "fbcd773caa937d0c7a02c301a1feea25612720ac3fa1ccb8bfd9d30d822911de", [:mix], [], "hexpm", "0690246a2478c1defd100b0c9b89b4ea280a22be9a7b313a8a058a2408a2fa70"},
1213
}

native/meeseeks_html5ever_nif/Cargo.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
name = "meeseeks_html5ever_nif"
33
version = "0.13.1"
44
authors = ["Mischov <mmischov@gmail.com>"]
5+
edition = "2018"
56

67
[lib]
78
name = "meeseeks_html5ever_nif"
89
path = "src/lib.rs"
910
crate-type = ["cdylib"]
1011

1112
[dependencies]
12-
rustler = "0.22"
13+
rustler = "0.27"
14+
15+
html5ever = "0.26"
16+
xml5ever = "0.17"
17+
markup5ever = "0.11"
1318

14-
html5ever = "0.22"
15-
xml5ever = "0.12"
16-
markup5ever = "0.7"
1719
tendril = "0.4"
20+
lazy_static = "1.4"

native/meeseeks_html5ever_nif/src/flat_dom.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use std::default::Default;
44

55
use html5ever::tree_builder::{ElementFlags, NodeOrText, QuirksMode, TreeSink};
66
use html5ever::{Attribute, QualName};
7+
78
use markup5ever::ExpandedName;
9+
use markup5ever::{local_name, namespace_url, ns};
810

911
use tendril::StrTendril;
1012

@@ -59,8 +61,8 @@ impl NodeEnum {
5961
fn script_or_style(&self) -> ScriptOrStyle {
6062
match *self {
6163
Element(ref name, ..) => match name.expanded() {
62-
expanded_name!(html "script") => ScriptOrStyle::Script,
63-
expanded_name!(html "style") => ScriptOrStyle::Style,
64+
markup5ever::expanded_name!(html "script") => ScriptOrStyle::Script,
65+
markup5ever::expanded_name!(html "style") => ScriptOrStyle::Style,
6466
_ => ScriptOrStyle::Neither,
6567
},
6668
_ => ScriptOrStyle::Neither,
@@ -91,10 +93,10 @@ impl Node {
9193
fn new(id: Id, node: NodeEnum) -> Node {
9294
Node {
9395
parent: Parent::None,
94-
id: id,
96+
id,
9597
children: vec![],
9698
last_string: false,
97-
node: node,
99+
node,
98100
}
99101
}
100102

@@ -195,7 +197,7 @@ impl TreeSink for FlatDom {
195197
fn get_template_contents(&mut self, target: &Self::Handle) -> Self::Handle {
196198
if let Element(_, _, true) = self.node(*target).node {
197199
// Use template element as document fragment
198-
target.clone()
200+
*target
199201
} else {
200202
panic!("not a template element!")
201203
}
@@ -336,7 +338,7 @@ impl TreeSink for FlatDom {
336338
// NIF Encoding
337339

338340
mod atoms {
339-
atoms! {
341+
rustler::atoms! {
340342
nil,
341343

342344
parent,
@@ -379,20 +381,20 @@ mod atoms {
379381
// Unsure if this is a great way of doing it, but it's the way
380382
// that produced the cleanest and least noisy code.
381383

382-
struct QNW<'a>(&'a QualName);
384+
struct Qnw<'a>(&'a QualName);
383385

384-
impl<'b> Encoder for QNW<'b> {
386+
impl<'b> Encoder for Qnw<'b> {
385387
fn encode<'a>(&self, env: Env<'a>) -> Term<'a> {
386-
let local: &str = &*self.0.local;
388+
let local: &str = &self.0.local;
387389
local.encode(env)
388390
}
389391
}
390392

391-
struct STW<'a>(&'a StrTendril);
393+
struct Stw<'a>(&'a StrTendril);
392394

393-
impl<'b> Encoder for STW<'b> {
395+
impl<'b> Encoder for Stw<'b> {
394396
fn encode<'a>(&self, env: Env<'a>) -> Term<'a> {
395-
let data: &str = &*self.0;
397+
let data: &str = self.0;
396398
data.encode(env)
397399
}
398400
}
@@ -437,7 +439,7 @@ impl Encoder for DataType {
437439
// Node
438440

439441
fn split_ns_and_tag(ns_tag: &str) -> (&str, &str) {
440-
let first_colon = ns_tag.find(':').unwrap_or_else(|| ns_tag.len());
442+
let first_colon = ns_tag.find(':').unwrap_or(ns_tag.len());
441443
match ns_tag.split_at(first_colon) {
442444
(tag, "") => ("", tag),
443445
(ns, tag) => (ns, &tag[1..]),
@@ -477,7 +479,7 @@ impl Encoder for Node {
477479
document_comment_atom,
478480
self.parent.encode(env),
479481
self.id.encode(env),
480-
STW(content).encode(env),
482+
Stw(content).encode(env),
481483
];
482484
Term::map_from_arrays(env, &keys, &values).ok().unwrap()
483485
}
@@ -492,7 +494,7 @@ impl Encoder for Node {
492494
self.parent.encode(env),
493495
self.id.encode(env),
494496
data_type.encode(env),
495-
STW(content).encode(env),
497+
Stw(content).encode(env),
496498
];
497499
Term::map_from_arrays(env, &keys, &values).ok().unwrap()
498500
}
@@ -514,9 +516,9 @@ impl Encoder for Node {
514516
document_doctype_atom,
515517
self.parent.encode(env),
516518
self.id.encode(env),
517-
STW(name).encode(env),
518-
STW(public).encode(env),
519-
STW(system).encode(env),
519+
Stw(name).encode(env),
520+
Stw(public).encode(env),
521+
Stw(system).encode(env),
520522
];
521523
Term::map_from_arrays(env, &keys, &values).ok().unwrap()
522524
}
@@ -529,10 +531,10 @@ impl Encoder for Node {
529531
let tag_atom = atoms::tag().encode(env);
530532
let attributes_atom = atoms::attributes().encode(env);
531533
let children_atom = atoms::children().encode(env);
532-
let (namespace, tag) = ns_and_tag(&name);
534+
let (namespace, tag) = ns_and_tag(name);
533535
let attribute_terms: Vec<Term<'a>> = attributes
534536
.iter()
535-
.map(|a| (QNW(&a.name), STW(&a.value)).encode(env))
537+
.map(|a| (Qnw(&a.name), Stw(&a.value)).encode(env))
536538
.collect();
537539
let keys = vec![
538540
struct_atom,
@@ -564,8 +566,8 @@ impl Encoder for Node {
564566
document_pi_atom,
565567
self.parent.encode(env),
566568
self.id.encode(env),
567-
STW(target).encode(env),
568-
STW(data).encode(env),
569+
Stw(target).encode(env),
570+
Stw(data).encode(env),
569571
];
570572
Term::map_from_arrays(env, &keys, &values).ok().unwrap()
571573
}
@@ -578,7 +580,7 @@ impl Encoder for Node {
578580
document_text_atom,
579581
self.parent.encode(env),
580582
self.id.encode(env),
581-
STW(content).encode(env),
583+
Stw(content).encode(env),
582584
];
583585
Term::map_from_arrays(env, &keys, &values).ok().unwrap()
584586
}

native/meeseeks_html5ever_nif/src/lib.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#[macro_use]
2-
extern crate rustler;
3-
extern crate html5ever;
4-
extern crate xml5ever;
5-
#[macro_use]
6-
extern crate markup5ever;
7-
extern crate tendril;
8-
91
use std::panic;
102

113
mod flat_dom;
@@ -28,7 +20,7 @@ use tendril::TendrilSink;
2820
// If using term_to_configs, remove this mod atoms and use commented
2921

3022
mod atoms {
31-
atoms! {
23+
rustler::atoms! {
3224
html5ever_nif_result,
3325

3426
ok,
@@ -46,7 +38,7 @@ use html5ever::tree_builder::TreeBuilderOpts;
4638
use html5ever::tree_builder::interface::QuirksMode;
4739
4840
mod atoms {
49-
atoms! {
41+
rustler::atoms! {
5042
html5ever_nif_result,
5143
5244
ok,
@@ -179,7 +171,11 @@ fn parse_xml<'a>(env: Env<'a>, document: Binary) -> NifResult<Term<'a>> {
179171
parse(ParserType::XmlDocument, env, document)
180172
}
181173

182-
rustler::init!("Elixir.MeeseeksHtml5ever.Native", [parse_html, parse_xml], load = load);
174+
rustler::init!(
175+
"Elixir.MeeseeksHtml5ever.Native",
176+
[parse_html, parse_xml],
177+
load = load
178+
);
183179

184180
fn load(_env: Env, _load_info: Term) -> bool {
185181
true

0 commit comments

Comments
 (0)