Libraryless. Click here for Pure Java version (2583L/17K).
1 | // if <head> block exists: put tag after <head> |
2 | // if not: add tag in front of the whole HTML |
3 | sS hAddToHead(S html, S tag) {
|
4 | L<S> tok = htmlTok(html); |
5 | L<S> head = first(findContainerTag(tok, "head")); |
6 | if (head == null) ret tag + html; |
7 | head.set(2, addLineBreak(tag) + head.get(2)); |
8 | ret join(tok); |
9 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1008417 |
| Snippet name: | hAddToHead - insert tag in <head> |
| Eternal ID of this version: | #1008417/3 |
| Text MD5: | 9ab12cbbaf4704035b1793b5db38e695 |
| Transpilation MD5: | 234e5dbb9e4f028a8c4e675c8204b46a |
| Author: | stefan |
| Category: | javax / html |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-06-05 16:33:03 |
| Source code size: | 315 bytes / 9 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 887 / 1014 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |