Coder Social home page Coder Social logo

Suppress CSS output about pelican-jupyter HOT 9 CLOSED

danielfrg avatar danielfrg commented on June 17, 2024 1
Suppress CSS output

from pelican-jupyter.

Comments (9)

danielfrg avatar danielfrg commented on June 17, 2024 1

Ok, I just added an IPYNB_IGNORE_CSS option that removes all CSS, hopefully that works better.

from pelican-jupyter.

Casyfill avatar Casyfill commented on June 17, 2024

+1 on that. How can I overwrite ipython style?

from pelican-jupyter.

danielfrg avatar danielfrg commented on June 17, 2024

This in is tricky guys :)

Removing all the ipython CSS will clearly result in something that is not presentable. Disabling their pygments might be possible.

It is possible to overwrite ipython/jupyter styles. I do that for my blog: https://github.com/danielfrg/danielfrg.github.io-source by just adding more CSS after the pelican converted html + css.

from pelican-jupyter.

mfitzp avatar mfitzp commented on June 17, 2024

@danielfrg I was really wanting to 'disable' it so I could include it myself via a CSS file (from the theme/etc.) — the advantage being that it's easier to override things if you can add the custom styles after the notebook ones (plus smaller page size... hosting the CSS on a static domain, etc.)

I was after a variable to toggle this behaviour — definitely don't want to do this by default!

from pelican-jupyter.

Casyfill avatar Casyfill commented on June 17, 2024

Exactly, that what I also end up using (a nasty hack around your hack):

def filter_css(style_text, path='plugins/ipynb/custom.css'):
        """
        HACK: IPython returns a lot of CSS including its own bootstrap.
        Get only the IPython Notebook CSS styles.
        """
        index = style_text.find('/*!\n*\n* IPython notebook\n*\n*/')
        if index > 0:
            style_text = style_text[index:]
        index = style_text.find('/*!\n*\n* IPython notebook webapp\n*\n*/')
        if index > 0:
            style_text = style_text[:index]

        style_text = re.sub(r'color\:\#0+(;)?', '', style_text)
        style_text = re.sub(r'\.rendered_html[a-z0-9,._ ]*\{[a-z0-9:;%.#\-\s\n]+\}', '', style_text)

        if path is not None and os.path.isfile(path):
            style_text += get_custom_css(path)
        else:
            print('custom.css is not found', os.getcwd())

        return '<style type=\"text/css\">{0}</style>'.format(style_text)

However, I guess I can just store "default" ipython css with my changes as an independent file, and replace all this functionalty with just link to this custom file.

from pelican-jupyter.

danielfrg avatar danielfrg commented on June 17, 2024

I don't think you need a hack like that, you can just remove ipython_css from this line: content = ipython_css + content + LATEX_CUSTOM_SCRIPT @ https://github.com/danielfrg/pelican-ipynb/blob/master/core.py#L115 and no CSS will be injected.

from pelican-jupyter.

Casyfill avatar Casyfill commented on June 17, 2024

probably replacing this injection with just a link to my custom css should do what I want.
Thanks!

from pelican-jupyter.

KentChun33333 avatar KentChun33333 commented on June 17, 2024

@danielfrg
Thanks for the modification, by setting IPYNB_IGNORE_CSS = True, everything works perfectly : )

from pelican-jupyter.

mfitzp avatar mfitzp commented on June 17, 2024

Thanks for this @danielfrg works great. I've just opened a PR to document this in the README.

from pelican-jupyter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.