classLinkBlotextendsInline { staticcreate(value) { let node = super.create(); // Sanitize url value if desired node.setAttribute('href', value); // Okay to set other non-format related attributes // These are invisible to Parchment so must be static node.setAttribute('target', '_blank'); return node; }
staticformats(node) { // We will only be called with a node already // determined to be a Link blot, so we do // not need to check ourselves return node.getAttribute('href'); } } LinkBlot.blotName = 'link'; LinkBlot.tagName = 'a';
classHeaderBlotextendsBlock { staticformats(node) { returnHeaderBlot.tagName.indexOf(node.tagName) + 1; } } HeaderBlot.blotName = 'header'; // Medium only supports two header sizes, so we will only demonstrate two, // but we could easily just add more tags into this array HeaderBlot.tagName = ['H1', 'H2'];
from selenium import webdriver from PIL import Image from io import BytesIO from os import path
defscreenshot(path): # Headless chrome
DRIVER = 'chromedriver'# add this to your $PATH chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') chrome_options.add_argument('--disable-gpu')
// Simple JavaScript Templating // John Resig - https://johnresig.com/ - MIT Licensed (function(){ var cache = {}; this.tmpl = functiontmpl(str, data){ // Figure out if we're getting a template, or if we need to // load the template - and be sure to cache the result. var fn = !/\W/.test(str) ? cache[str] = cache[str] || tmpl(document.getElementById(str).innerHTML) : // Generate a reusable function that will serve as a template // generator (and which will be cached). newFunction("obj", "var p=[],print=function(){p.push.apply(p,arguments);};" + // Introduce the data as local variables using with(){} "with(obj){p.push('" + // Convert the template into pure JavaScript str .replace(/[\r\t\n]/g, " ") .split("<%").join("\t") .replace(/((^|%>)[^\t]*)'/g, "$1\r") .replace(/\t=(.*?)%>/g, "',$1,'") .split("\t").join("');") .split("%>").join("p.push('") .split("\r").join("\\'") + "');}return p.join('');"); // Provide some basic currying to the user return data ? fn( data ) : fn; }; })();