Skip to content

Commit 3ef74e6

Browse files
authored
Merge pull request #8 from askonomm/7-doctype-is-missing-on-a-round-trip-of-html-nodes-html
#7: Fixes an issue where `!doctype` would be left out when creating n…
2 parents 94a3ce3 + 325f430 commit 3ef74e6

3 files changed

Lines changed: 133 additions & 7 deletions

File tree

src/dompa/coordinates.cljc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
{:coord-type :text, :coord-name :dompa/text})))
118118

119119
(def ^:private void-elements
120-
#{"area" "base" "br" "col" "embed" "hr" "img"
120+
#{"!DOCTYPE" "!doctype" "area" "base" "br" "col" "embed" "hr" "img"
121121
"input" "link" "meta" "param" "source" "track" "wbr"})
122122

123123
(defn- handle-opening-tag [{:keys [stack unified coord coord-name start]}]
@@ -201,9 +201,7 @@
201201
"Parses a given HTML node attribute string into a
202202
key-value pair."
203203
[attr]
204-
(->> (partition-by #(= % \=) attr)
205-
(filter #(not= (-> % first) \=))
206-
(map #(reduce str %))))
204+
(str/split attr #"=" 2))
207205

208206
(defn- normalize-html-attr-str
209207
"Normalizes a given HTML attribute string. If it
@@ -221,9 +219,8 @@
221219
treated as boolean attributes, and are always `true`."
222220
[html-attr-str]
223221
(let [[k v] (html-attr-str->k-v html-attr-str)
224-
k (keyword k)
225-
v (if (nil? v) true (normalize-html-attr-str v))]
226-
{k v}))
222+
k (keyword k)]
223+
{k (if (nil? v) true (normalize-html-attr-str v))}))
227224

228225
(defn- html->str->node-attrs-reducer-fn
229226
"Returns a reducer function with initial state of `attrs-html`."
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Welkom op de homepagina van Michiel Borkent</title>
5+
<meta charset="utf-8">
6+
<meta content="width=device-width, initial-scale=1" name="viewport">
7+
<link href="css/bootstrap.min.css" rel="stylesheet">
8+
<link href="css/lavish-bootstrap.css" rel="stylesheet">
9+
</head>
10+
<body>
11+
<div class="container">
12+
<div class="row">
13+
<div class="col-md-8">
14+
<div class="jumbotron">
15+
<p class="lead">Michiel Borkent<br>Software developer, speaker, Clojure professional</p>
16+
</div>
17+
18+
<div class="panel panel-default">
19+
<div class="panel-heading"><h3 class="panel-title">Business info</h3></div>
20+
<div class="panel-body">
21+
<ul class="list-unstyled">
22+
<li>Michiel Borkent - Clojure development</li>
23+
<br>
24+
<li><a href="mailto:michielborkent@gmail.com">michielborkent@gmail.com</a></li>
25+
<br>
26+
<li>Netherlands Chamber of Commerce / Kamer van Koophandel: 66357454</li>
27+
</ul>
28+
</div>
29+
</div>
30+
31+
<div class="panel panel-default">
32+
<div class="panel-heading"><h3 class="panel-title">Curriculum vitae</h3></div>
33+
<div class="panel-body">
34+
<ul class="list-unstyled">
35+
<li><a href="cv/cv-EN.pdf">Curriculum vitae (EN)</a></li>
36+
<li><img src="img/dutchflag_14px.jpg"> <a href="cv/cv.pdf">Curriculum vitae</a></li>
37+
</ul>
38+
</div>
39+
</div>
40+
41+
<div class="panel panel-default">
42+
<div class="panel-heading"><h3 class="panel-title">Open source projects</h3></div>
43+
<div class="panel-body">
44+
<ul class="list-unstyled">
45+
<li><a href="https://github.com/borkdude/babashka">Babashka</a><span>: a fast-starting scripting environment for Clojure</span></li>
46+
<li><a href="https://github.com/borkdude/clj-kondo">Clj-kondo</a><span>: a linter for Clojure that sparks joy</span></li>
47+
<li><a href="https://github.com/borkdude/sci">Small Clojure Interpreter</a></li>
48+
<li><a href="https://github.com/borkdude/jet">Jet</a><span>: CLI to transform between JSON, EDN and Transit</span></li>
49+
<li><a href="https://github.com/borkdude/edamame">Edamame</a><span>: configurable EDN/Clojure parser with location metadata</span></li>
50+
<li><a href="https://github.com/borkdude/re-find">Re-find</a><span>: find functions using spec</span></li>
51+
</ul>
52+
</div>
53+
</div>
54+
55+
<div class="panel panel-default">
56+
<div class="panel-heading"><h3 class="panel-title">Talks</h3></div>
57+
<div class="panel-body">
58+
<ul class="list-unstyled">
59+
<li>Babashka and GraalVM; taking Clojure to new places - <a href="https://youtu.be/3EUMA6bd-xQ">video</a>, <a href="https://speakerdeck.com/borkdude/babashka-and-graalvm-taking-clojure-to-new-places-at-clojure-nyc-meetup">slides</a> and <a href="https://github.com/borkdude/babashka">code</a><span class="text-muted"> July 11th 2020, Clojure/NYC</span></li>
60+
<li>Babashka and the Small Clojure Interpreter: using Clojure in new contexts - <a href="https://www.youtube.com/watch?v=Nw8aN-nrdEk">video</a>, <a href="https://speakerdeck.com/borkdude/babashka-and-the-small-clojure-interpreter-at-clojured-2020">slides</a> and <a href="https://github.com/borkdude/babashka">code</a><span class="text-muted"> February 2020, ClojureD, Berlin Germany</span></li>
61+
<li>Clj-kondo: a linter for Clojure that sparks joy - <a href="https://www.youtube.com/watch?v=MB3vVREkI7s">video</a>, <a href="https://speakerdeck.com/borkdude/clj-kondo-a-linter-for-clojure-code-that-sparks-joy-at-clojutre-2019">slides</a><a href="https://github.com/borkdude/clj-kondo">code</a><span class="text-muted"> September 27th 2019, ClojuTRE, Helsinki Finland</span></li>
62+
<li>Re-find: discover functions with spec - <a href="https://www.youtube.com/watch?v=Ygrml6tyrq0">video</a>, <a href="https://speakerdeck.com/borkdude/re-find-discover-functions-with-spec">slides</a> and <a href="https://borkdude.github.io/re-find.web/">demo</a><span class="text-muted"> April 6th 2019, Dutch Clojure Days</span></li>
63+
<li>Functional Programming in Practice - <a href="https://github.com/borkdude/fp-hu-may-2016">repo and slides</a><span class="text-muted"> May 9th 2016, Hogeschool Utrecht</span></li><li>Full stack Clojure - <a href="https://github.com/borkdude/full-stack-clojure-han-okt-2015">repo and slides</a><span class="text-muted"> October 1 2015, Hogeschool Arnhem-Nijmegen</span></li>
64+
<li>Functional programming in the browser with ClojureScript - <a href="https://github.com/borkdude/sytac-core-async">repo and slides</a><span class="text-muted"> July 29 2015, <a href="http://www.meetup.com/Sytac-Dev-Jam/events/223330464/">Sytac Devjam</a></span></li>
65+
<li>ClojureScript &lt;3 React - <a href="http://domcode.org/videos/2015/05/26/clojurescript-and-reactjs/">video</a>, <a href="slides/domcode-may-26-2015.pdf">slides</a> and <a href="https://github.com/borkdude/domcode-cljs-react">code</a><span class="text-muted"> May 26 2015, <a href="http://www.meetup.com/DomCode/events/222548762/">DomCode meetup</a></span></li>
66+
<li>Reagent - ClojureScript interface to React - <a href="slides/react-amsterdam-feb-12-2015.pdf">slides</a> and <a href="https://github.com/borkdude/react-amsterdam">code</a><span class="text-muted"> Feb. 12 2015, <a href="http://www.meetup.com/React-Amsterdam/events/220160608/">React Amsterdam</a></span></li>
67+
<li>ClojureScript interfaces to React - <a href="http://vimeo.com/111289716">video</a>, <a href="oredev14/ClojureScript_interfaces_to_React.pdf">slides</a> and <a href="https://github.com/borkdude/oredev2014">code</a> <span class="text-muted"> Nov. 6 2014, <a href="http://oredev.org/2014/speakers/michiel-borkent">Øredev</a>, Malmö Sweden</span></li>
68+
<li>ClojureScript for the web - <a href="http://vimeo.com/111214648">video</a>, <a href="oredev14/ClojureScript_for_the_web.pdf">slides and </a><a href="https://github.com/borkdude/oredev2014">code</a> <span class="text-muted"> Nov. 6 2014, <a href="http://oredev.org/2014/speakers/michiel-borkent">Øredev</a>, Malmö Sweden</span></li>
69+
<li>ClojureScript/Om/Reagent - <a href="http://vimeo.com/109915707">video</a> and <a href="fpamsclj/fpamsclj.pdf"> slides </a><span class="text-muted">Oct. 16 2014, FP AMS, Amsterdam Netherlands</span></li><li>Immutable Stack (clojure workshop) - <a href="devnology-immutable-stack-04-10-2014/presentation.html">slides</a> and <a href="https://github.com/borkdude/immutable-webapp">code </a><span class="text-muted">Oct. 10 2014, Devnology, Leusden Netherlands</span></li>
70+
<li><img src="img/dutchflag_14px.jpg"> Clojure introductie - <a href="gastcollege-han-28-05-2014/presentation.html">slides </a><span class="text-muted">Jun. 20 2013, Dec. 19 2013, May 5 2014, Hogeschool Arnhem-Nijmegen Netherlands</span></li>
71+
</ul>
72+
</div>
73+
</div>
74+
75+
<div class="panel panel-default">
76+
<div class="panel-heading"><h3 class="panel-title">Writings</h3></div>
77+
<div class="panel-body">
78+
<ul class="list-unstyled">
79+
<li><a href="//jaxenter.com/clojure-alternative-java-169315.html">Clojure: a mature alternative to Java</a></li>
80+
<li><img src="img/dutchflag_14px.jpg"> Artikel in Java Magazine januari 2016: <a href="nljug/18_21_Clojure.pdf">PDF</a>, <a href="https://nljug.org/java-magazine/clojure/">HTML</a></li>
81+
<li><a href="//blog.michielborkent.nl">Blog about Clojure, Clojurescript and Datomic</a></li>
82+
</ul>
83+
</div>
84+
</div>
85+
86+
<div class="panel panel-default">
87+
<div class="panel-heading"><h3 class="panel-title">Courses</h3></div>
88+
<div class="panel-body">
89+
<ul class="list-unstyled">
90+
<li><img src="img/dutchflag_14px.jpg"> <a href="clojurecursus/index.html">Clojure lesmateriaal</a> <span class="text-muted">(2012-2013)</span></li>
91+
<li><img src="img/dutchflag_14px.jpg"> <a href="downloads/dotnet-public.zip">Lesmateriaal C# / .NET programmeren</a> <span class="text-muted">(2011-2013)</span></li>
92+
</ul>
93+
</div>
94+
</div>
95+
96+
<div class="panel panel-default">
97+
<div class="panel-heading"><h3 class="panel-title">Etc.</h3></div>
98+
<div class="panel-body">
99+
<ul class="list-unstyled">
100+
<li><img src="img/dutchflag_14px.jpg"> <a href="https://www.facebook.com/groups/tssnl">The Starch Solution Nederland community</a> <span class="text-muted">(&gt; 2 Aug. 2014)</span></li>
101+
<li><img src="img/dutchflag_14px.jpg"> <a href="//www.eetvoorjeleven.nu">Mijn blog over gezond eten</a><span class="text-muted">(&gt; Aug. 2013)</span></li>
102+
<li><a href="//www.michielborkent.nl/potmwebarchive/index.html">Website of my old band Picture of the Moon</a> <span class="text-muted">(2001-2008)</span> - Music: <a href="https://www.michielborkent.nl/potmwebarchive/www.pictureofthemoon.net/media/mp3/ad">Ageless Day</a>, <a href="https://www.michielborkent.nl/potmwebarchive/www.pictureofthemoon.net/media/mp3/wc">Waxing Crescent</a></li>
103+
<li><a href="mmm/finalthesis.pdf">Final Thesis Music Mind Machine</a>,<a href="mmm/presentatie.pdf">slides</a> and <a href="mmm/drempdemo.html">demo</a> <span class="text-muted">(2005)</span></li>
104+
<li><a href="mmm/stageverslag.pdf">Internship report Music Mind Machine</a>, <img src="img/dutchflag_14px.jpg"> <a href="mmm/presentatie-stage.pdf">presentatie</a> and <a href="mmm/tutorial.html">tutorial</a> <span class="text-muted">(2005)</span></li>
105+
</ul>
106+
</div>
107+
</div>
108+
</div>
109+
<div class="col-md-4">
110+
<p><img alt="Michiel" class="img-responsive" src="img/avatar-zwart-wit.jpg"></p>
111+
<p class="text-right"><a href="//github.com/borkdude"><img alt="View Michiel Borkent's profile on Github" src="//github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" width="25%"></a></p>
112+
<p class="text-right"><a href="//stackoverflow.com/users/6264/michiel-borkent"><img alt="Stackoverflow" height="58" src="//stackoverflow.com/users/flair/6264.png" title="profile for Michiel Borkent at Stack Overflow, Q&amp;A for professional and enthusiast programmers" width="208"></a></p>
113+
<p class="text-right"><a class="twitter-follow-button" data-align="right" data-show-count="false" data-size="large" data-width="208px" href="https://twitter.com/borkdude">Follow @borkdude</a><script type="text/javascript"></script></p>
114+
</div>
115+
</div>
116+
</div>
117+
</body>
118+
</html>

test/dompa/round_trip_test.clj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(ns dompa.round-trip-test
2+
(:require [clojure.test :refer [deftest is testing]]
3+
[dompa.nodes :as nodes]
4+
[dompa.html :as html]))
5+
6+
(deftest round-trip-test
7+
(testing "michiel borkent website"
8+
(let [input-html (slurp "test/dompa/html/michiel_borkent.html")
9+
nodes (html/->nodes input-html)
10+
output-html (nodes/->html nodes)]
11+
(is (= input-html output-html)))))

0 commit comments

Comments
 (0)