Comments (4)
Nope. A total oversight on my part. Let me get into it!
from htmlreader.
Actually, I think what you're looking for already works. The elements that are always self-enclosing (aka. void elements) work just fine:
let img = HTMLElement(tagName: "img", attributes: ["src": "updog.png"])
println(img.serializedFragment)
// prints: <img src="updog.png">
Some elements have an optional end tag (like <li>
or <p>
), but there isn't any advantage I can see to dealing with all the special cases, so HTMLReader always includes end tags:
let li = HTMLElement(tagName: "li", attributes: nil)
println(li.serializedFragment)
// prints: <li></li>
And if you're worried about the trailing /
just before the >
, don't be: it's optional.
Does all of that makes sense?
from htmlreader.
@nolanw thanks a lot for pointing me at html specs :) I was sure that / is obligatory.
And thanks for a great lib!
from htmlreader.
You're most welcome!
from htmlreader.
Related Issues (20)
- Elements after self-closing tag will be added as child of previous tag HOT 1
- Does not work with latest SPM HOT 3
- Can't upload to Itunes bacause of "No CFBundleVersion " HOT 6
- Build issues with Xcode 8.3 HOT 3
- Class name prefix? HOT 7
- Carthage Xcode 9 beta build fail HOT 2
- Xcode 9 build errors HOT 2
- Could HTMLReader detect the page dismiss? HOT 2
- Xcode 9.3 build errors HOT 2
- Is it possible to replace a tag with its own innerHTML? Insert HTMLNode.children into parent.mutableChildren? HOT 3
- values of type 'NSUInteger' should not be used as format arguments HOT 1
- "Duplicate symbol" linker error with TapjoySDK HOT 2
- Crash in CFStringGetCharactersPtr HOT 1
- Xcode 11 build errors HOT 4
- Combining certain selectors doesn't work HOT 1
- How to save a web page as an html file, including pictures? HOT 5
- Can jsoup support HOT 3
- Unable to clone project because of deprecated git protocol for submodule
- documentation missing HOT 10
- Crash within runAdoptionAgencyAlgorithmForTagName HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from htmlreader.