Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <p>Demo of idea of how a CSS-like idea can be used for author intent. Idea is from <a href="https://codepen.io/bkardell/pen/xxLKOxo?editors=1111">Brian Kardell's codepen</a> with extended examples. The code uses CSS selectors and a custom property (<code>speech</code>) to generate text to use as the value of <code>aria-label</code>.</p>
<p>Note: these examples won't display well in Chrome/Edge as the examples depend upon some MathML features not yet implemented.
  This does not affect the computation of <code>aria-label</code></p>
Example 1:
<math>
  <mrow data-intent="point">
    <mo>(</mo>
    <mi class="arg1">0</mi>
    <mo>,</mo>
    <mi class="arg2">5</mi>
    <mo>)</mo>
  </mrow>
</math>
<br/>
Example 2:
<math>
<mover data-intent="line-segment">
  <mrow>
    <msup class="start" data-intent="modified-identifier">
      <mi class="base">A</mi>
      <mo class="modifier">&#x2032;</mo>
    </msup>
    <mo>&#x2063;</mo>
    <msup class="end" data-intent="modified-identifier">
      <mi class="base">B</mi>
      <mo class="modifier">&#x2032;</mo>
    </msup>
  </mrow>
  <mo>¯</mo>
</mover>
</math>
<br/>
Example 3:
<math>
  <msub data-intent="point-coordinate">
    <msup class="point" data-intent="modified-identifier">
      <mi class="base">B</mi>
      <mo class="modifier">&#x2032;</mo>
    </msup>
    <mi class="coord">x<mi>
  </msub>
</math>
   
              
            
!

CSS

              
                [data-intent="point"] {
   --speech: "the point " text(.arg1) " comma " text(.arg2);
}

[data-intent="line-segment"] {
   --speech: "the line segment " text(.start) "  " text(.end);
}

[data-intent="modified-identifier"] {
   --speech: text(.base) " " text(.modifier);
}

[data-intent="point-coordinate"] {
   --speech: "the " text(.coord) "coordinate of " text(.point);
}
              
            
!

JS

              
                function parseIntentExpression(str, context) {
  const regex = /\W[^\"]*/gm;
  let m,  mode = '', out = ''
  //console.warn("parse: intent/str=" + str + ", el/context=" + context.outerHTML)
  while ((m = regex.exec(str)) !== null) {
      // avoid infinite loops with zero-width matches
      if (m.index === regex.lastIndex) {
          regex.lastIndex++;
      }
      m.forEach((match, groupIndex) => {
        let tok = match.substring(1)
         if ((mode === '')  && match[0]==='"') {
          mode = "string"
          out += tok
         } else if (tok !== "" ) {
           tok = tok.trim()
           if (tok.startsWith('text(')) {
             tok = tok.substring(5, tok.length-1)
             console.warn("querying '" + tok + "'")
             let el = context.querySelector(tok)
             console.warn("outerHTML:" + el.outerHTML)
             console.warn("textContent:" + el.textContent)
             if(el) {
               out += el.textContent
             } else {
               console.warn('no element matching ', tok)
             }
           } else {
             console.warn(`unsupported token ${tok} in expression ${str}`)
           }
           mode = "" //reset
         }
      });
  }
  return out
}

// a 'static' profile, could be improved with a defined lifecycle for recalc
document.addEventListener("DOMContentLoaded", ()=> {
  let intents = document.querySelectorAll('[data-intent]')
  intents.forEach(intentEl => {
    let intentExpression = getComputedStyle(intentEl).getPropertyValue('--speech')
    let value = parseIntentExpression(intentExpression, intentEl)
    
    // somehow, attach the meaning
    intentEl.setAttribute('aria-label', value)
  })
})
              
            
!
999px

Console