This repository has been archived by the owner on Mar 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Add title tags to HTML #1
Open
daxelrod
wants to merge
10
commits into
allisonrandal:master
Choose a base branch
from
daxelrod:topic/html-title
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It reflects the current behavior where the head0 command paragraph is not added as a title tag when add_body_tags is used.
Move output of html and body tags from start_Document() into emit() We don't actually know at start_Document() time whether there will be a =head0 command paragraph tag to make into a title tag. Luckily, we *do* know this by the first time emit() is called, because, as the tutorial says, "The file should always start with a =head0". This commit ammounts to a no-op change.
We now output the html tag in start_Document, but the body tag in emit. This will make adding a title tag in the correct place easier. This also has the side effect of moving the link element for css above the body tag.
After <html>, output <head>. Before <body>, output </head>.
The text in a =head0 command paragraph is now saved into a 'title_text' hash element in our parser object. This change does not affect our output at all.
A slight change in approach, in order to get ordering of output correct. The logic for outputting the title, closing head, and beginning body have now moved into a new method begin_body_if_necessary(). Both emit() and end_head0() now call this method. We now use a flag 'in_html_head' rather than 'body_tags_emitted' for consistency with other in_* flags. Note that we do everything but actually output the title tag at this point. Also that because of how emit already works, there is now always a blank line before </head> in the output. This is the only externally-visible change.
We now actually output a title tag with the contents of the =head0 command paragraph, if one exists.
Add a new test for a document with body tags and css turned on, where the document additionally has a =head0 command paragraph, which creates a <title> tag.
This does not otherwise change code or output.
|
I noticed it's been a little while since I sent this pull request. Is there anything you'd like me to do to improve it, or are you not interested in this feature? If you've been too busy to have a look at it, that's fine too. :) |
That all sounds reasonable. Would you mind rebasing against the current trunk? |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pod::PseudoPod::HTML now outputs
<title>
tags with the contents of=head0
whenadd_body_tags
is on. We'll also throw in<head>
tags absolutely free! :)Here's a more specific description of the new behavior:
add_body_tags
is on,<head>
is output after<html>
and</head>
is output before<body>
.add_body_tags
is on, and a=head0
command paragraph appears as the first piece of content, its text is added in<title>
tags in the head. It still appears normally as an<h1>
in the body.add_body_tags
is on, andadd_css_tags
is also on, the<link>
to the stylesheet appears in the head.Even though I think all of this is nifty, here are a few reasons I could think of that you not want to pull from me (it's your call whether they're big deals or not):
add_css_tags
is on, butadd_body_tags
is off. (If that is an invalid combination, the docs need an update).=head0
command paragraph is encountered, but isn't the first piece of content in the document. Pod::PseudoPod::Tutorial does say "The file should always start with a =head0" but I'm not sure whether this fails gracefully if the order is different.<head>
and right after<body>
is somewhat odd.No matter what, thank you for publishing Modern Perl, which is what inspired me to do all of this in the first place! (Specifically, I wanted to make the generation of its HTML version even better.) Also, thank you for all of the other work you do, which has significantly improved my life as a programmer.