{"id":18096268,"url":"https://github.com/bredele/marc","last_synced_at":"2025-10-24T08:05:55.721Z","repository":{"id":14851457,"uuid":"17574607","full_name":"bredele/marc","owner":"bredele","description":":part_alternation_mark: Markdown as a dynamic template engine","archived":false,"fork":false,"pushed_at":"2020-04-28T15:38:56.000Z","size":561,"stargazers_count":148,"open_issues_count":5,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-11T02:43:32.233Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bredele.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-09T21:52:50.000Z","updated_at":"2024-07-11T15:33:54.000Z","dependencies_parsed_at":"2022-09-23T23:50:57.620Z","dependency_job_id":null,"html_url":"https://github.com/bredele/marc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fmarc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fmarc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fmarc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fmarc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bredele","download_url":"https://codeload.github.com/bredele/marc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253435505,"owners_count":21908136,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-31T19:13:13.680Z","updated_at":"2025-10-24T08:05:55.672Z","avatar_url":"https://github.com/bredele.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# marc\n\n  \u003e Markdown as a dynamic template engine\n\n\nMarkdown is a text-to-HTML conversion tool for web writers. With a plain easy-to-write text you can create a website, a blog, a todo list, a slideshow or even a project presentation (like I've done here on github). However it is mostly used to generate static content.\n\n`marc` makes markdown a dynamic conversion engine with integrated **templates** that **updates automatically** when the underlying data changes. It also allows you to create **filters** or **partials** and makes easy to create content dynamically from a database.\n\n## Installation\n\n`marc` works on both client and server side:\n  \n  with [component](http://component.io):\n\n    $ component install bredele/marc\n\n  with [nodejs](http://nodejs.org):\n\n    $ npm install marc\n\n\n### Command line\n\nInstall globally:\n\n    $ npm install -g marc\n\n```\nUsage: marc [\u003cinput\u003e] [\u003coutput\u003e]\n\nExamples:\n\n  # pass an input and output file:\n  $ marc input.md output.html\n  \n```\n\n## Usage\n\n  `marc` can be initialized with an optional data.\n\n```js\nvar marc = require('marc')(data);\n```\n\n### Basic\n\n  `marc` generates html from markdown.\n\n```js\nmarc('I am using __markdown__.');\n//\u003cp\u003eI am using \u003cstrong\u003emarkdown\u003c/strong\u003e.\u003c/p\u003e\n```\n\n### Templating\n\n  `marc` is also a template engine! It makes markdown less static and allows you to substitute variables (double brackets `{{}}` with any data.\n\n```js\nmarc.set('label', 'marc!');\nmarc('I am using __markdown__ with {{label}}.', true);\n//\u003cp\u003eI am using \u003cstrong\u003emarkdown\u003c/strong\u003e with marc!.\u003c/p\u003e\n```\n\n### Dynamic\n\n  `marc` makes your markdown dynamic! It updates automatically when the underlying data changes.\n\n```js\nmarc('I am using __narkdown__ with {{label}}.', function(val) {\n  //\u003cp\u003eI am using \u003cstrong\u003emarkdown\u003c/strong\u003e with marc!.\u003c/p\u003e\n  //\u003cp\u003eI am using \u003cstrong\u003emarkdown\u003c/strong\u003e with github.\u003c/p\u003e \n});\n\nmarc.set('label', 'marc!');\nmarc.set('label', 'github');\n```\n\n## Features\n\n### Partials\n\n  `marc` allows you to use partials (`{\u003e name }`)\n\n\n```js\nmarc.partial('hello', '__{{ label }}__!');\nmarc('This is a partial: {\u003e hello }.', function(val){\n  //\u003cp\u003eThis is a partial: \u003cstrong\u003ehello world\u003c/strong\u003e!\u003c/p\u003e\n});\n\nmarc.set('label', 'hello world');\n```\n\n### Filters\n\n  `marc` allows you to apply filter(s) to your markdown in a unix-like fashion.\n\n```js\nmarc.filter('hello', function(str) {\n  return 'hello ' + str + '!';\n});\nmarc('# {{ name } | hello}.', true);\n//\u003ch1\u003ehello world!.\u003c/h1\u003e\n```\n\n  \u003e filters can be chained and reused multiple times.\n\n\u003c!-- ### Expressions\n\n  You can use grouping, binary operators, identifiers, comparators and ternary operators...\n\n```js\nmarc.set('items', ['item1', 'item2']);\nmarc('There is __{{items.length}}__ item{{ items.length !== 1 ? 's' : '' }}.', true);\n//\u003cp\u003eThere is \u003cstrong\u003e2\u003c/strong\u003e items.\u003c/p\u003e\n```\n\n  ...directly from your markdown. --\u003e\n\n### Config\n\n  `marc` use [marked](https://github.com/chjj/marked) and allows to set markdown options as following:\n\n```js\n//single options\nmarc.config('sanitize', true);\n\n//multiple options\nmarc.config({\n  gfm:true,\n  smartypants:true\n})\n```\n\n  or get options:\n\n```js\nmarc.config('sanitize');\n```\n\n\n## API\n\n### General\n\n#### marc(str, fn)\n\n  Generate HTML from markdown.\n\n```js\nmarc('I am using __markdown__.');\nmarc('hello __markdown__ with {{label}}', true);\nmarc('hello __markdown__ with {{label}}', function(val) {\n  //do something on change\n});\n```\n\n  Second argument is optional (substitute template variables if truethy).\n\n\n#### marc.filter(str, fn)\n\n  Add template filter. \n\n```js\nmarc.filter('hello', function(str) {\n  return 'hello ' + str + '!';\n});\nmarc('# {{ label } | hello}', true);\n\n```\n\n  Second argument is a function and takes the template variable as argument.\n\n#### marc.partial(name, str)\n\n  Add partial. \n\n```js\nmarc.partial('hello','__{{ name }}__');\nmarc('hello {\u003e hello }', true);\n```\n\n#### marc.config(name, val)\n\n  Set markdown options.\n\n```js\nmarc.config('sanitize','true');\nmarc.config({\n  sanitize: false,\n  gfm: true\n});\n```\n\n  or get options:\n\n\n```js\nmarc.config('sanitize');\n```\n\n### Datastore\n\n  `marc` is basically a mixin of [datastore](http://github.com/bredele/datastore) and exposes its entire api through the option `marc.data`. Here's an example of computed property:\n\n```js\nmarc.data.compute('name',function() {\n  return this.firstName + ' ' + this.lastName;\n});\n```\n\n  However, `marc` overrides some of the most used store handler such as `get` and `set` just for the beauty of code.\n\n#### .set(name, data)\n\n Set an attribute `name` with data object.\n\nobject store:\n```js\nmarc.set('nickname','bredele');\n```\n\n Or update data:\n\n```js\nmarc.set({\n  nickname: 'olivier',\n  lastname: 'wietrich'\n});\n```\n\n#### .get(name)\n\n Get an attribute `name`.\n\n```js\nmarc.get('nickname');\n```\n\n## License\n\n  The MIT License (MIT)\n\n  Copyright (c) 2014 \u003cOlivier Wietrich\u003e\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy\n  of this software and associated documentation files (the \"Software\"), to deal\n  in the Software without restriction, including without limitation the rights\n  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n  copies of the Software, and to permit persons to whom the Software is\n  furnished to do so, subject to the following conditions:\n\n  The above copyright notice and this permission notice shall be included in\n  all copies or substantial portions of the Software.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n  THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbredele%2Fmarc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbredele%2Fmarc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbredele%2Fmarc/lists"}