Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Conversation

@mco-gh
Copy link
Contributor

@mco-gh mco-gh commented Apr 9, 2018

No description provided.

@mco-gh mco-gh requested a review from x1ddos April 9, 2018 19:13
Copy link
Contributor

@x1ddos x1ddos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Marc! Aside from the minor comment, two things feel missing:

func (hw *htmlWriter) image(n *types.ImageNode) {
hw.writeString("<img")
if n.Alt != "" {
hw.writeFmt(` alt="%s"`, n.Alt)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writeFmt(" alt=%q", n.Alt) is safer, I think, in case n.Alt already contains quotes.
the same for title.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@mco-gh
Copy link
Contributor Author

mco-gh commented Apr 9, 2018

@x1ddos Thx for quick review, comments fixed, PTAL.

Copy link
Contributor

@x1ddos x1ddos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a couple minor comments. Feel free to submit after that.

break
n = types.NewImageNode(v.Val)
}
if v.Key == "alt" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather use switch, which won't go into all the checks like these ifs do. Also, note strings.ToLower:

switch strings.ToLower(v.Key) {
case "src":
  n = types.NewImageNode(v.Val)
case "alt":
  alt = v.Val
case "title":
  title = v.Val
}

if n.Title != "" {
mw.writeString("\"")
mw.writeString(n.Title)
mw.writeString("\"")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're missing a space before "title text". Also, probably safer to use quoted string:

if n.Title != "" {
  mw.writeString(fmt.Sprintf(" %q", n.Title))
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@mco-gh mco-gh merged commit 48ed6f8 into master Apr 10, 2018
@mco-gh mco-gh deleted the alt branch April 10, 2018 13:48
samtstern added a commit to samtstern/tools that referenced this pull request Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.