Changes to importer.scroll.pub

ffff:72.234.190.31
ffff:72.234.190.31
2 months ago
Updated index.scroll
index.scroll
Changed around line 1
- scrollVersionLink
ffff:72.234.190.31
ffff:72.234.190.31
2 months ago
Updated index.scroll
index.scroll
Changed around line 1
+ scrollVersionLink
ffff:72.234.190.31
ffff:72.234.190.31
2 months ago
Updated index.scroll
index.scroll
Changed around line 1
- editButton
+ editButton /edit.html
ffff:72.234.190.31
ffff:72.234.190.31
2 months ago
Updated index.scroll
index.scroll
Changed around line 1
+ editButton
Breck Yunits
Breck Yunits
2 months ago
latex.js
Changed around line 1
- section: "# ",
- subsection: "## ",
- subsubsection: "### ",
- paragraph: "*",
- begin: {
- itemize: "- ",
- enumerate: "1. ",
- quote: "> ",
- verbatim: "code\n",
- center: "center\n",
- figure: "figure\n",
- },
+ 'section': '# ',
+ 'subsection': '## ',
+ 'subsubsection': '### ',
+ 'paragraph': '*',
+ 'begin': {
+ 'itemize': '- ',
+ 'enumerate': '1. ',
+ 'quote': '> ',
+ 'verbatim': 'code\n',
+ 'center': 'center\n',
+ 'figure': 'figure\n',
+ }
- textbf: "*",
- textit: "_",
- texttt: "`",
- emph: "_",
- href: "link",
+ 'textbf': '*',
+ 'textit': '_',
+ 'texttt': '`',
+ 'emph': '_',
+ 'href': 'link'
-
+
- scroll = scroll.replace(/%.*$/gm, "");
-
+ scroll = scroll.replace(/%.*$/gm, '');
+
+ // Handle \input commands first
+ scroll = this.convertInputCommands(scroll);
+
-
+
-
+
-
+
-
- // Handle lists
- scroll = this.convertLists(scroll);
-
- // Handle images
- scroll = this.convertImages(scroll);
-
+
-
+
-
+
+ convertInputCommands(text) {
+ // Match \input{filename} with or without .tex extension
+ const inputRegex = /\\input\{([^}]+)\}/g;
+ return text.replace(inputRegex, (match, filename) => {
+ // Remove .tex extension if present and add .scroll
+ const scrollFile = filename.replace(/\.tex$/, '') + '.scroll';
+ return `${scrollFile}`;
+ });
+ }
+
-
+
-
+
- const prefix = this.blockCommands.begin[env] || "";
-
- if (env === "itemize" || env === "enumerate") {
+ const prefix = this.blockCommands.begin[env] || '';
+
+ if (env === 'itemize' || env === 'enumerate') {
- } else if (env === "verbatim") {
- return `${prefix}${content.trim()}`;
- } else if (env === "figure") {
+ } else if (env === 'verbatim') {
+ return `code\n${content.trim()}`;
+ } else if (env === 'figure') {
-
+
- .split("\n")
- .map((line) => " " + line)
- .join("\n");
-
+ .split('\n')
+ .map(line => ' ' + line)
+ .join('\n');
+
-
+
+ convertListItems(content, type) {
+ const marker = type === 'itemize' ? '- ' : '1. ';
+ return content
+ .split('\\item')
+ .slice(1) // Skip first empty element
+ .map(item => marker + item.trim())
+ .join('\n') + '\n';
+ }
+
-
+
- Object.keys(this.blockCommands).forEach((cmd) => {
- if (cmd === "begin") return;
- const regex = new RegExp(`\\\\${cmd}{([^}]+)}`, "g");
+ Object.keys(this.blockCommands).forEach(cmd => {
+ if (cmd === 'begin') return;
+ const regex = new RegExp(`\\\\${cmd}{([^}]+)}`, 'g');
-
+
-
+
- Object.keys(this.inlineCommands).forEach((cmd) => {
- const regex = new RegExp(`\\\\${cmd}{([^}]+)}`, "g");
+ Object.keys(this.inlineCommands).forEach(cmd => {
+ const regex = new RegExp(`\\\\${cmd}{([^}]+)}`, 'g');
- if (cmd === "href") {
- const [url, text] = content.split("}{");
- return `${text}\n link ${url} ${text}`;
+ if (cmd === 'href') {
+ // Handle \href{url}{text}
+ const [url, linkText] = content.split('}{');
+ return `${linkText.replace('}', '')}\n link ${url} ${linkText.replace('}', '')}`;
-
+
- "\\&": "&",
- "\\%": "%",
- "\\$": "$",
- "\\#": "#",
- "\\_": "_",
- "\\{": "{",
- "\\}": "}",
- "~": " ",
- "``": '"',
- "''": '"',
+ '\\&': '&',
+ '\\%': '%',
+ '\\$': '$',
+ '\\#': '#',
+ '\\_': '_',
+ '\\{': '{',
+ '\\}': '}',
+ '~': ' ',
+ '``': '"',
+ "''": '"'
-
+
- Object.keys(charMap).forEach((char) => {
- result = result.replace(
- new RegExp(char.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"),
- charMap[char],
- );
+ Object.keys(charMap).forEach(char => {
+ result = result.replace(new RegExp(char.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), charMap[char]);
-
+
- convertListItems(content, type) {
- const marker = type === "itemize" ? "- " : "1. ";
- const lines = content
- .split("\\item")
- .slice(1) // Skip first empty element
- .map((item) => marker + item.trim())
- .join("\n");
- return lines + "\n";
- }
-
-
- const imagePath = content.match(includegraphicsRegex)?.[1] || "";
- const caption = content.match(captionRegex)?.[1] || "";
-
+
+ const imagePath = content.match(includegraphicsRegex)?.[1] || '';
+ const caption = content.match(captionRegex)?.[1] || '';
+
-
+
- result = result.replace(/\\cite\{([^}]+)\}/g, "^$1");
-
+ result = result.replace(/\\cite\{([^}]+)\}/g, '^$1');
+
- result = result.replace(/\\ref\{([^}]+)\}/g, "^$1");
-
+ result = result.replace(/\\ref\{([^}]+)\}/g, '^$1');
+
- return (
- text
- .replace(/\n\s*\n\s*\n/g, "\n\n") // Remove extra blank lines
- .replace(/[ \t]+$/gm, "") // Remove trailing whitespace
- .trim() + "\n"
- ); // Ensure single newline at end
+ return text
+ .replace(/\n\s*\n\s*\n/g, '\n\n') // Remove extra blank lines
+ .replace(/[ \t]+$/gm, '') // Remove trailing whitespace
+ .trim() + '\n'; // Ensure single newline at end
- // module.exports = LaTeXToScroll;
+ // For Node.js environment
+ if (typeof module !== 'undefined' && module.exports) {
+ module.exports = LaTeXToScroll;
+ }
markdown.js
Changed around line 1
- // Mapping of common Markdown patterns
Changed around line 18: class MarkdownToScroll {
- footnoteRef: /\[\^(\d+)\]/g,
- footnoteDef: /^\[\^(\d+)\]:\s*(.+)$/,
- // Split into lines for block-level processing
- let lines = markdown.trim().split("\n");
- let scroll = "";
+ if (!markdown) return '';
+
+ let lines = markdown.toString().trim().split('\n');
+ let scroll = '';
- let codeBlockContent = "";
- let inTable = false;
- let tableContent = [];
+ let codeBlockContent = '';
+ let inList = false;
+ let listIndentLevel = 0;
- const line = lines[i];
-
- // Handle code blocks first
- if (line.startsWith("```")) {
+ let line = lines[i].trimEnd();
+
+ // Handle code blocks
+ if (line.startsWith('```')) {
- codeBlockContent = "";
+ codeBlockContent = '';
- scroll += this.convertCodeBlock(codeBlockContent.trim()) + "\n\n";
+ scroll += 'code\n' + codeBlockContent.trim() + '\n\n';
- codeBlockContent += line + "\n";
+ codeBlockContent += line + '\n';
- // Handle tables
- if (line.startsWith("|")) {
- if (!inTable) {
- inTable = true;
- tableContent = [];
- }
- if (!this.blockPatterns.tableDelimiter.test(line)) {
- tableContent.push(line);
- }
+ // Handle horizontal rules
+ if (this.blockPatterns.horizontalRule.test(line)) {
+ scroll += '---\n\n';
- } else if (inTable) {
- scroll += this.convertTable(tableContent) + "\n\n";
- inTable = false;
- tableContent = [];
- // Process block-level patterns
- let processed = false;
-
- // Headers
+ // Handle headers
- scroll +=
- "#".repeat(headerMatch[1].length) +
- " " +
- this.convertInlineElements(headerMatch[2]) +
- "\n\n";
- processed = true;
- }
-
- // Horizontal Rule
- if (this.blockPatterns.horizontalRule.test(line)) {
- scroll += "---\n\n";
- processed = true;
+ scroll += '#'.repeat(headerMatch[1].length) + ' ' +
+ this.convertInlineElements(headerMatch[2]) + '\n\n';
+ continue;
- // Blockquotes
+ // Handle blockquotes
- scroll += "> " + this.convertInlineElements(blockquoteMatch[1]) + "\n";
- processed = true;
+ scroll += '> ' + this.convertInlineElements(blockquoteMatch[1]) + '\n';
+ continue;
- // Unordered Lists
+ // Handle lists
- if (ulMatch) {
- scroll += "- " + this.convertInlineElements(ulMatch[1]) + "\n";
- processed = true;
- }
-
- // Ordered Lists
- if (olMatch) {
- scroll += "1. " + this.convertInlineElements(olMatch[1]) + "\n";
- processed = true;
- }
-
- // Footnote Definitions
- const footnoteMatch = line.match(this.blockPatterns.footnoteDef);
- if (footnoteMatch) {
- scroll +=
- "^" +
- footnoteMatch[1] +
- " " +
- this.convertInlineElements(footnoteMatch[2]) +
- "\n";
- processed = true;
- }
-
- // Regular paragraphs
- if (!processed && line.trim()) {
- scroll += "* " + this.convertInlineElements(line) + "\n\n";
+ if (ulMatch || olMatch) {
+ const content = (ulMatch || olMatch)[1];
+ const marker = ulMatch ? '- ' : '1. ';
+ scroll += marker + this.convertInlineElements(content) + '\n';
+ continue;
- // Preserve blank lines
- if (!line.trim()) {
- scroll += "\n";
+ // Handle regular paragraphs
+ if (line.trim()) {
+ scroll += '* ' + this.convertInlineElements(line) + '\n\n';
+ } else {
+ scroll += '\n';
Changed around line 95: class MarkdownToScroll {
- let result = text;
-
- // Convert images before links (to avoid nested parsing issues)
- result = result.replace(
- this.inlinePatterns.image,
- (match, alt, src, title) => {
- let scroll = `\nimage ${src}`;
- if (alt) scroll += `\n caption ${alt}`;
- return scroll;
- },
- );
+ if (!text) return '';
+ let result = text.toString();
+
+ // Convert images before links
+ result = result.replace(this.inlinePatterns.image, (match, alt, src, title) => {
+ let scroll = `\nimage ${src}`;
+ if (alt) scroll += `\n caption ${alt}`;
+ return scroll;
+ });
- result = result.replace(
- this.inlinePatterns.link,
- (match, text, url, title) => {
- let scroll = text + "\n link " + url + " " + text;
- if (title) scroll += "\n title " + title;
- return scroll;
- },
- );
+ result = result.replace(this.inlinePatterns.link, (match, text, url) => {
+ return `${text}\n link ${url} ${text}`;
+ });
- .replace(this.inlinePatterns.bold, "*$1*")
- .replace(this.inlinePatterns.italic, "_$1_")
- .replace(this.inlinePatterns.code, "`$1`")
- .replace(this.inlinePatterns.strikethrough, "strike $1")
- .replace(this.inlinePatterns.footnoteRef, "^$1");
+ .replace(this.inlinePatterns.bold, '*$1*')
+ .replace(this.inlinePatterns.italic, '_$1_')
+ .replace(this.inlinePatterns.code, '`$1`')
+ .replace(this.inlinePatterns.strikethrough, 'strike $1');
- convertCodeBlock(content) {
- return "code\n" + content;
- }
-
- convertTable(tableContent) {
- let scroll = "table\n";
- scroll += " data\n";
-
- // Convert each table row to CSV format
- tableContent.forEach((row) => {
- const cells = row
- .split("|")
- .filter((cell) => cell.trim()) // Remove empty cells from start/end
- .map((cell) => cell.trim())
- .map((cell) => this.convertInlineElements(cell))
- .join(",");
- scroll += " " + cells + "\n";
- });
-
- return scroll;
- }
-
- return (
- scroll
- .replace(/\n{3,}/g, "\n\n") // Remove extra blank lines
- .replace(/[ \t]+$/gm, "") // Remove trailing whitespace
- .trim() + "\n"
- ); // Ensure single newline at end
+ return scroll
+ .replace(/\n{3,}/g, '\n\n') // Remove extra blank lines
+ .replace(/[ \t]+$/gm, '') // Remove trailing whitespace
+ .replace(/\^undefined\n/g, '') // Remove undefined references
+ .replace(/\n\n+/g, '\n\n') // Normalize multiple newlines
+ .trim() + '\n'; // Ensure single newline at end
- // module.exports = MarkdownToScroll;
+ // For Node.js environment
+ if (typeof module !== 'undefined' && module.exports) {
+ module.exports = MarkdownToScroll;
+ }
ffff:72.234.190.31
ffff:72.234.190.31
2 months ago
Updated claude.html
claude.html
Changed around line 23
- padding-top: 1rem;
+ padding-top: 0.2rem;
ffff:72.234.190.31
ffff:72.234.190.31
2 months ago
Updated claude.html
claude.html
Changed around line 33
- margin-bottom: 1rem;
+ margin-bottom: 0.2rem;
ffff:72.234.190.31
ffff:72.234.190.31
2 months ago
Updated claude.html
claude.html
Changed around line 23
+ padding-top: 1rem;
ffff:72.234.190.31
ffff:72.234.190.31
2 months ago
Updated claude.html
claude.html
Changed around line 33
+ margin-top: 0;
ffff:72.234.190.31
ffff:72.234.190.31
2 months ago
Updated claude.html
claude.html
Changed around line 32
- margin-bottom: 2rem;
+ margin-bottom: 1rem;