Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <!-- 7 Aout 2017 - 22h-23h - @FGRibreau 

 This is a simple Proof Of Concept.
 Based on the ideas from http://bit.ly/2vzsf0n
 - Display syntax error (rapid feedback loop)
 - Support more operators
<div class="root">
    <textarea id="text">
  Le 35e Montreux Jazz Festival s'est terminé [[affiche durée depuis: 16.07.2017]]. Son bilan est excellent.
  [[affiche si date < 02-07-2017]]Le Montreux Jazz festival commencera le 2 juillet 2017. Juste avant cette édition, nous avons interviewé son directeur.[[fin]][[affiche si date > 02.07.2017]]Le directeur du Montreux Jazz Festival s'est livré au Temps quelques jours avant la 51e édition de la manifestation[[fin]] - Mathieu Jaton, le festival vit une année charnière.
              * {
  padding: 0;
  margin: 0;
  font-family: monospace;
  font-size: 1rem;
  width: 100%;
  height: 100vh;
.root {
  display: flex;
  flex-direction: row;
.root > div {
textarea {

span {

 This is a simple Proof Of Concept.
 Based on the ideas from http://bit.ly/2vzsf0n
 - Display syntax error (rapid feedback loop)
 - Support more operators
const subscribeToTextChange = (f) => {
  const el = document.getElementById("text");
  el.addEventListener('keyup', function(e){f(e.target.value)}, false);

const META_LANGUAGE = /\[{2}([^\]])+\]{2}/g;

const operators = [
    is: exp => /affiche dur[é|e]e depuis/i.test(exp),
    run: (text, tokens) => {
      const { index, expression, rawExp } = tokens.shift();
      const [date] = /([0-9].*)$/g.exec(expression);
      return text.replace(
        moment(date, "DDMMYYYY").locale("fr").fromNow()
    is: exp => /affiche si date/i.test(exp),
    run: (text, tokens) => {
      const { expression, rawExp } = tokens.shift();
      const date = expression.replace(/affiche si date\s+[\<\>]/i, "").trim();
      if (
        moment()[expression.includes("<") ? "isBefore" : "isAfter"](
      ) {
        // true => only remove first and second expression
        return text.replace(rawExp, "").replace(tokens.shift().rawExp, "");

      // false => remove section
      const { rawExp: rawExp2 } = tokens.shift();
      return (
        text.substring(0, text.indexOf(rawExp)) +
        text.substring(text.indexOf(rawExp2) + rawExp2.length)

function parse(text) {
  let match,
    tokens = [];
  META_LANGUAGE.index = 0;
  while ((match = META_LANGUAGE.exec(text))) {
      index: match.index,
      rawExp: match[0],
      expression: match[0].replace(/^\[\[/g, "").replace(/\]\]$/g, "")
  return { text: text, tokens: tokens };

function exec({ text, tokens }) {
  do {
    const op = operators.find(op => op.is(tokens[0].expression));
    if (!op) {
      throw new Error(`Unsupported operation "${tokens[0].expression}"`);
    text = op ? op.run(text, tokens) : text;
  } while (tokens.length > 0);

  return text;

const displayResult = text => (document.querySelector("span").innerText = text);

const flow = (...fs) => v => fs.reduce((m, f) => f(m), v);
const tap = f => v => {
  return v;
const debug = v => console.debug(JSON.stringify(v, null, 2));

const run = flow(parse, tap(debug), exec, displayResult);


🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.