New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Standard Variables: Doh! #199

Closed
neocotic opened this Issue May 19, 2013 · 2 comments

Comments

Projects
None yet
1 participant
@neocotic
Member

neocotic commented May 19, 2013

How have I not thought of adding these before:

  • html - HTML of the entire page
  • markdown - Entire page in Markdown
  • text - Text of the entire page

Obviously, these will only work in non-protected (i.e. non-chrome) pages but this would be very useful I imagine. Especially when coupled with the new wordCount operation that's being added in #193.

This'll probably be best implemented by only fetching the HTML from the content script and deriving the rest on-demand.

@ghost ghost assigned neocotic May 19, 2013

@neocotic

This comment has been minimized.

Member

neocotic commented May 19, 2013

I can't decide what the scope of html should be (i.e. the entire page source or just that of the body element). My current thinking is that html should be the entire page source but text and markdown should only apply to the contents of the body element ( unless it doesn't exist? ). For example;

# content.coffee
html: document.documentElement.outerHTML

# background.coffee
markdown: ->
  markdown = ''

  if @html
    container = document.createElement 'html'
    container.innerHTML = @html
    $container = $ container

    $body = $container.find 'body'
    markdown = md if $body.length then $body.html() else $container.html()

  markdown

text: ->
  text = ''

  if @html
    container = document.createElement 'html'
    container.innerHTML = @html
    $container = $ container

    $body = $container.find 'body'
    text = if $body.length then $body.text() else $container.text()

  text
@neocotic

This comment has been minimized.

Member

neocotic commented May 19, 2013

These new variables have been included in PR neocotic/template-chrome#2.

@neocotic neocotic closed this May 19, 2013

@neocotic neocotic added the accepted label Nov 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment