Skip to content

Commit

Permalink
page title should be first h1 ignoring location
Browse files Browse the repository at this point in the history
  • Loading branch information
tlnagy committed Sep 14, 2016
1 parent 70225b6 commit ca0d7a2
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/Writers/HTMLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -566,19 +566,18 @@ end

"""
Tries to guess the page title by looking at the `<h1>` headers and returns the
header contents as a `Nullable` (nulled if the algorithm was unable to determine
the header).
It is assumed that the intended page title can only be guessed if the very first
block of the page is `<h1>` heading. If there is something before the first heading
or the first heading is a lower level heading, then the return value is nulled.
header contents of the first `<h1>` on a page as a `Nullable` (nulled if the algorithm
was unable to find any `<h1>` headers).
"""
function pagetitle(page::Documents.Page)
if length(page.elements) >= 1 && isa(page.elements[1], Base.Markdown.Header{1})
Nullable{Any}(page.elements[1].text)
else
Nullable{Any}()
title = Nullable{Any}()
for element in page.elements
if isa(element, Base.Markdown.Header{1})
title = Nullable{Any}(element.text)
break
end
end
title
end

function pagetitle(ctx, navnode::Documents.NavNode)
Expand Down

0 comments on commit ca0d7a2

Please sign in to comment.