Skip to content
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

og:description picks up <script... if text is short #22

Closed
cranmer opened this issue Oct 1, 2020 · 4 comments · Fixed by #23
Closed

og:description picks up <script... if text is short #22

cranmer opened this issue Oct 1, 2020 · 4 comments · Fixed by #23
Labels
bug Something isn't working

Comments

@cranmer
Copy link

cranmer commented Oct 1, 2020

It seems that if the text of a page is very short that the og:description may pick up HTML tags in the header that aren't properly escaped, and the og:description text will be displayed on the web page.

I am using jupyterbook, which uses sphinx.
My jupyterbook has this in the _config.yml file

  extra_extensions:
  - sphinxext.opengraph

Here's an example source page
https://github.com/cranmer/stats-ds-book/blob/master/book/statistics/cramer-rao-bound.md

This gets compiled into
https://cranmer.github.io/stats-ds-book/statistics/cramer-rao-bound.html

The problematic part seems to be

  <meta property="og:description" content="coming soon<script type="text/x-thebe-config"> { requestKernel: true, binderOptions: { repo: "binder-examples/jupyter-stacks-datascience", ref: "master", }, codeMirrorConfig: { theme: "abcdef", mod..." />

As the webpage will display (not always visible, but you can see it on a phone or wide screen

{ requestKernel: true, binderOptions: { repo: "binder-examples/jupyter-stacks-datascience", ref: "master", }, codeMirrorConfig: { theme: "abcdef", mod..." />

It seems this was picked up from the HTML

  <div class="section" id="cramer-rao-bound">
<h1>Cramer-Rao Bound<a class="headerlink" href="#cramer-rao-bound" title="Permalink to this headline">¶</a></h1>
<p>coming soon</p>
</div>

    <script type="text/x-thebe-config">
    {
        requestKernel: true,
        binderOptions: {
            repo: "binder-examples/jupyter-stacks-datascience",
            ref: "master",
        },
        codeMirrorConfig: {
            theme: "abcdef",
            mode: "python"
        },
        kernelOptions: {
            kernelName: "python3",
            path: "./statistics"
        },
        predefinedOutput: true
    }
    </script>

Example:
Screen Shot 2020-10-01 at 9 08 54 AM

IMG_7466

@cranmer
Copy link
Author

cranmer commented Oct 1, 2020

related issue in jupyterbook jupyter-book/jupyter-book#1008

@cranmer
Copy link
Author

cranmer commented Oct 1, 2020

I will probably want to update the example page I sent with more text, which may hide the problem.
So here's another page with the same issue that I will leave alone for testing:
https://cranmer.github.io/stats-ds-book/test-sphinxext-opengraph.html

@TheTripleV
Copy link
Member

After building your repo, I have noticed this issue occurring on many of the pages. The issue seems to lie in raw tags. sphinxext-opengraph does not currently ignore raw tags. Once raw tags are excluded, the description is created correctly.

@TheTripleV
Copy link
Member

The latest release contains the fix for this issue, @cranmer .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants