Giter VIP home page Giter VIP logo

Comments (7)

adrinux avatar adrinux commented on August 17, 2024

Another thought – a custom parser to scan and expand the figure elements. But can you stack parsers, just be listing them in the project configuration? with list order defining the order they run?

from punch.

adrinux avatar adrinux commented on August 17, 2024

And do even content images have to go in the templates folder? Seems the wrong place somehow. Makes sense for css background images etc, but content images?

from punch.

laktek avatar laktek commented on August 17, 2024

Hi Adrian,

You could try splitting up the long-text into several markdown files and render them along with the images. For this you may need to create a special page template and have definite structure on where the images would appear within the content.

For example, you can create a extended content directory named _long_page and inside it store the sections of content as markdown: intro.markdown, current_situation.markdown, proposed_solution.markdown & conclusion.markdown.

A page template structured as follows can render the above content with images. You can create a custom helper to output the figures.

{{> header}}

<body>
{{intro}}

{{figure}}{{intro_image}}{{/figure}}

{{current_situation}}

{{figure}}{{current_situation_image}}{{/figure}

....

</body>
{{> footer}}

from punch.

laktek avatar laktek commented on August 17, 2024

Custom parser built on top of Markdown parser that can support special helper tags could also be an option. But let's try the simple solution first.

Also, I do agree content images doesn't really belong inside the templates directory. I'll try to introduce better content image fetching support in a future version.

from punch.

adrinux avatar adrinux commented on August 17, 2024

For this particular project the content I want to add is HTML. It could be cut and pasted into a processed layout template and would be a perfectly valid HTML document. So splitting up the content isn't simple as such, it will involve a lot of extra work. So lots of extra work to convert perfectly valid usable HTML into...HTML :(

Markdown has its uses, particular when content is being written from scratch, but for a lot of the projects I do, it tends to get in the way, despite the fact that you can include HTML in markdown.

After thinking about this I think what I want is an html parser. It could start with something as simple as including a file with .html extension as is, but ideally would run something like htmltidy or htmlawed first to fix issues and possibly sanitise content (the latter opening up the possibility of allowing third parties to edit content).
I'll be working on that myself this week, but it does seem like punch ought to be able to deal with HTML out of the box, so maybe something to add in the future.

Will close this issue for now.

from punch.

adrinux avatar adrinux commented on August 17, 2024

Just as an FYI I hacked markdown.js into html.js, (placed in node_modules/html.js inside my current project) adding that to config.json is enough to disable Punch's default markdown parsing. And gets me where I need to be to finish my current project.

/*
 * Parser for html content
 * No filtering or modification is done, the files are simply included as is.
 * Responisiblity for validity and sanitization is left to the content creator.
*/

module.exports = {

    supportedExtensions: [".html"],

    parse: function(input, callback){
        var self = this;
        var output, err;

        try {
            output = input;
        } catch(error){
            err = error;
        }

        return callback(err, output);
    },

};

from punch.

laktek avatar laktek commented on August 17, 2024

Cool. You can release it as a proper parser plugin if you like - https://github.com/laktek/punch/wiki/Adding-Content-Parsers

from punch.

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.