Skip to content

Instantly share code, notes, and snippets.

Last active Sep 30, 2021
What would you like to do?
The Telegram InstantView template rule for
# Maintained by: Hung-I WANG <>
~version: "2.1"
# e.g. `/1234`, `/1234/zh-tw`
?path: /\d+/(\w+/)?
# # The Telegram IV parser treats the webpage incorrectly, which results in mal-structured HTML/XML. Here try to fix it by rewrapping <meta> into <head> and moving them to the front of <body>.
# @prepend("<head>"): /html
# @prepend_to($@): //meta
# Overwrite the default author data hence it is not corret/proper.
author: //a[@rel="author"]/text()
author_url: //a[@rel="author"]/@href
channel: @OpeningSourceOrg
body: //div[contains(@class, "post-content")]
# Reformat tag list
@before(<hr>): $body//div[has-class("post-tags")]
@prepend("Tags: "): $body//div[has-class("post-tags")]
@before("#"): $body//div[has-class("post-tags")]/span/a
@after(" "): $body//div[has-class("post-tags")]/span
@wrap("<u>"): $body//div[has-class("post-tags")]/span/a
# Pull the footer copyright from otherwhere ouside the body
@append_to($body): //div[has-class("post-copyright")]
@replace_tag("<em>"): $body//div[has-class("post-copyright")]
@wrap("<p>"): $@
# Generate `figure>img` by copying and manipulate `meta[property="og:image"]` and take it as the cover.
@clone: (/html/head/meta[@property="og:image"])[0]
@replace_tag("<img>"): $@
@before_el(//article): $@
$temp: $@
@set_attr("src", @content): $@
@wrap("<figure>"): $temp
cover: $@
# To fix: Element <img> is not supported in <a>
# From:
@split_parent: //a/img
@split_parent: //p/img
@split_parent: //figure/table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment