Merge pull request #10764 from alaviss/htmlparser-doc

htmlparser: update example
This commit is contained in:
Dominik Picheta 2019-03-01 20:46:36 +00:00 • committed by GitHub
commit 5d67208e34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,6 +30,7 @@
## ending with the extension ``.rst`` and convert them to ``.html``. ## ending with the extension ``.rst`` and convert them to ``.html``.
## ##
## .. code-block:: Nim ## .. code-block:: Nim
## :test:
## ##
## import htmlparser ## import htmlparser
## import xmltree # To use '$' for XmlNode ## import xmltree # To use '$' for XmlNode
@ -41,9 +42,8 @@
## let html = loadHTML("input.html") ## let html = loadHTML("input.html")
## ##
## for a in html.findAll("a"): ## for a in html.findAll("a"):
## let href = a.attrs["href"] ## if a.attrs.hasKey "href":
## if not href.isNil: ## let (dir, filename, ext) = splitFile(a.attrs["href"])
## let (dir, filename, ext) = splitFile(href)
## if cmpIgnoreCase(ext, ".rst") == 0: ## if cmpIgnoreCase(ext, ".rst") == 0:
## a.attrs["href"] = dir / filename & ".html" ## a.attrs["href"] = dir / filename & ".html"
## ##