Comments (7)
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.
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.
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.
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.
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.
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.
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)
- TypeError: Cannot call method 'getTime' of null HOT 5
- Ability to add self-contained widgets (css, js, template) HOT 2
- Issues displaying {{date}} HOT 2
- style failed to compile HOT 2
- Cannot start server Connect has no method 'logger' HOT 1
- Can't get this working in a docker container
- Pulling bundle assets from outside local directory
- Punch Plugin: How to find the file path to the "templates" directory? HOT 2
- S3 gzip support
- Failed to read the configurations. HOT 1
- Copy command fails with paths that contain spaces HOT 1
- Failing basic setup HOT 2
- Trouble Implementing Autoprefixer compiler/minifier
- is this still happening? HOT 1
- Themes?
- What is the best practice for i18n?
- Creating intro.markdown in contents/_index during tutorial doesn't render the HTML HOT 1
- Custom compiler works only on generate HOT 4
- Javascript does not bundle HOT 1
- Mime.extension and Mime.lookup is not a function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from punch.