From 8f90de01fdd393c9a9d60a366e13e5fa995fc0af Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 14:44:04 +0100 Subject: [PATCH 01/21] test: add markdown table test file --- test/markdown/tables.md | 106 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 test/markdown/tables.md diff --git a/test/markdown/tables.md b/test/markdown/tables.md new file mode 100644 index 00000000..d3658a3c --- /dev/null +++ b/test/markdown/tables.md @@ -0,0 +1,106 @@ +# Markdown Tables Test + +This file contains various markdown table examples to test table parsing and rendering. + +## Basic Table + +| Column 1 | Column 2 | +| ------------- | ------------- | +| Cell 1, Row 1 | Cell 2, Row 1 | +| Cell 1, Row 2 | Cell 2, Row 2 | + +## Table with Alignment + +| Left | Centered | Right | +| :----------- | :--------------: | -------------------------: | +| This is left | Text is centered | And this is right-aligned | +| More text | Even more text | And even more to the right | + +## Table with Formatting + +| Name | Location | Food | +| ------- | ------------ | ------- | +| *Alice* | **New York** | `Pizza` | +| Bob | Paris | Crepes | + +## Table with Links + +| Name | Website | Description | +| ----- | -------------------------- | --------------------- | +| Alice | [GitHub](https://github.com) | Code repository | +| Bob | [Nostr](https://nostr.com) | Decentralized network | + +## Table with Code Blocks + +| Language | Example | +| -------- | -------------------------- | +| Python | `print("Hello, World!")` | +| JavaScript | `console.log("Hello")` | +| SQL | `SELECT * FROM users` | + +## Wide Table (Testing Horizontal Scroll) + +| Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 | Column 7 | Column 8 | +| -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | +| Data 1 | Data 2 | Data 3 | Data 4 | Data 5 | Data 6 | Data 7 | Data 8 | +| More | Content | Here | To | Test | Scrolling| Behavior | Mobile | + +## Table with Mixed Content + +| Item | Price | Status | Notes | +| ---- | ----- | ------ | ------------------------------ | +| Apple | $1.00 | ✅ In stock | Fresh from the farm | +| Banana | $0.50 | ⚠️ Low stock | Last few left | +| Orange | $1.25 | ❌ Out of stock | Coming next week | + +## Table with Empty Cells + +| Name | Email | Phone | +| ---- | ----- | ----- | +| Alice | alice@example.com | | +| Bob | | 555-1234 | +| Charlie | charlie@example.com | 555-5678 | + +## Table with Long Text + +| Short | Medium Length Column | Very Long Column That Contains A Lot Of Text And Should Wrap Properly | +| ----- | -------------------- | -------------------------------------------------------------------- | +| A | This is medium text | This is a very long piece of text that should wrap to multiple lines when displayed in the table cell. It should maintain proper formatting and readability. | + +## Table with Numbers + +| Rank | Name | Score | Percentage | +| ---- | ---- | ----- | ---------- | +| 1 | Alice | 95 | 95% | +| 2 | Bob | 87 | 87% | +| 3 | Charlie | 82 | 82% | + +## Table with Special Characters + +| Symbol | Name | Usage | +| ------ | ---- | ----- | +| `\|` | Pipe | Used in markdown tables | +| `\*` | Asterisk | Used for bold/italic | +| `\#` | Hash | Used for headings | + +## Table with Headers Only + +| Header 1 | Header 2 | Header 3 | +| -------- | -------- | -------- | + +## Single Column Table + +| Item | +| ---- | +| First | +| Second | +| Third | + +## Table with Nested Formatting + +| Description | Example | +| ----------- | ------- | +| Bold and italic | ***Important*** | +| Code and link | `[Click here](https://example.com)` | +| Strikethrough | ~~Old price~~ | + From a4c8a7d68b6b4464aedf45dea7d05104a8e45936 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 14:45:42 +0100 Subject: [PATCH 02/21] feat: add script to publish markdown test files to Nostr using nak --- scripts/publish-markdown.sh | 146 ++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100755 scripts/publish-markdown.sh diff --git a/scripts/publish-markdown.sh b/scripts/publish-markdown.sh new file mode 100755 index 00000000..2fdfc3c1 --- /dev/null +++ b/scripts/publish-markdown.sh @@ -0,0 +1,146 @@ +#!/bin/bash + +# Script to publish markdown files from test/markdown/ to Nostr using nak +# Usage: +# ./scripts/publish-markdown.sh [filename] [relay1] [relay2] ... +# ./scripts/publish-markdown.sh # Interactive mode +# ./scripts/publish-markdown.sh tables.md # Publish specific file +# ./scripts/publish-markdown.sh tables.md wss://relay.example.com # With relay + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +MARKDOWN_DIR="$PROJECT_ROOT/test/markdown" + +# Check if nak is installed +if ! command -v nak &> /dev/null; then + echo "Error: nak is not installed or not in PATH" + echo "Install from: https://github.com/fiatjaf/nak" + exit 1 +fi + +# Function to publish a markdown file +publish_file() { + local file_path="$1" + shift # Remove first argument, rest are relay URLs + local relays=("$@") + local filename=$(basename "$file_path") + local identifier="${filename%.md}" # Remove .md extension + + echo "📝 Publishing: $filename" + echo " Identifier: $identifier" + + # Read the markdown content + local content=$(cat "$file_path") + + # Extract title from first H1 if available, otherwise use filename + local title=$(echo "$content" | grep -m 1 "^# " | sed 's/^# //' || echo "$identifier") + + # Build nak command + local nak_cmd="nak event -k 30023 -d \"$identifier\" -t \"title=\\\"$title\\\"\" --content -" + + # Add relays if provided + if [ ${#relays[@]} -gt 0 ]; then + nak_cmd="$nak_cmd ${relays[*]}" + echo " Relays: ${relays[*]}" + else + echo " Note: No relays specified. Event will be created but not published." + echo " Add relay URLs as arguments to publish, e.g.: wss://relay.example.com" + fi + + # Publish as kind 30023 (NIP-23 blog post) + # The "d" tag is required for replaceable events (kind 30023) + # Using the filename (without extension) as the identifier + echo "$content" | eval "$nak_cmd" + + if [ $? -eq 0 ]; then + echo "✅ Successfully published: $filename" + else + echo "❌ Failed to publish: $filename" + return 1 + fi +} + +# Check for NOSTR_SECRET_KEY +if [ -z "$NOSTR_SECRET_KEY" ]; then + echo "⚠️ Warning: NOSTR_SECRET_KEY environment variable not set" + echo " You can set it with: export NOSTR_SECRET_KEY=your_key_here" + echo " Or use --prompt-sec flag (nak will prompt for key)" + echo "" +fi + +# Main logic +if [ $# -eq 0 ]; then + # No arguments: list all markdown files and let user choose + echo "Available markdown files:" + echo "" + + files=("$MARKDOWN_DIR"/*.md) + if [ ! -e "${files[0]}" ]; then + echo "No markdown files found in $MARKDOWN_DIR" + exit 1 + fi + + # Display files with numbers + declare -a file_array + i=1 + for file in "${files[@]}"; do + filename=$(basename "$file") + echo " $i) $filename" + file_array[$i]="$file" + ((i++)) + done + + echo "" + echo "Enter file number(s) to publish (space-separated), or 'all' for all files:" + read -r selection + + echo "" + echo "Enter relay URLs (space-separated, or press Enter to skip):" + read -r relay_input + + # Parse relay URLs + relays=() + if [ -n "$relay_input" ]; then + read -ra relays <<< "$relay_input" + fi + + if [ "$selection" = "all" ]; then + # Publish all files + for file in "${files[@]}"; do + publish_file "$file" "${relays[@]}" + echo "" + done + else + # Publish selected files + for num in $selection; do + if [ -n "${file_array[$num]}" ]; then + publish_file "${file_array[$num]}" "${relays[@]}" + echo "" + else + echo "⚠️ Invalid selection: $num" + fi + done + fi +else + # Argument provided: publish specific file + filename="$1" + shift # Remove filename, rest are relay URLs + relays=("$@") + + # If filename doesn't end with .md, add it + if [[ ! "$filename" =~ \.md$ ]]; then + filename="${filename}.md" + fi + + file_path="$MARKDOWN_DIR/$filename" + + if [ ! -f "$file_path" ]; then + echo "Error: File not found: $file_path" + exit 1 + fi + + publish_file "$file_path" "${relays[@]}" +fi + From 496b329e82710c9952be67f0843dade760770f14 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 14:45:49 +0100 Subject: [PATCH 03/21] fix: improve command construction in publish-markdown script --- scripts/publish-markdown.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/publish-markdown.sh b/scripts/publish-markdown.sh index 2fdfc3c1..a3e85a57 100755 --- a/scripts/publish-markdown.sh +++ b/scripts/publish-markdown.sh @@ -37,12 +37,8 @@ publish_file() { # Extract title from first H1 if available, otherwise use filename local title=$(echo "$content" | grep -m 1 "^# " | sed 's/^# //' || echo "$identifier") - # Build nak command - local nak_cmd="nak event -k 30023 -d \"$identifier\" -t \"title=\\\"$title\\\"\" --content -" - # Add relays if provided if [ ${#relays[@]} -gt 0 ]; then - nak_cmd="$nak_cmd ${relays[*]}" echo " Relays: ${relays[*]}" else echo " Note: No relays specified. Event will be created but not published." @@ -52,7 +48,21 @@ publish_file() { # Publish as kind 30023 (NIP-23 blog post) # The "d" tag is required for replaceable events (kind 30023) # Using the filename (without extension) as the identifier - echo "$content" | eval "$nak_cmd" + # Build command array to avoid eval issues + local cmd_args=( + "event" + "-k" "30023" + "-d" "$identifier" + "-t" "title=\"$title\"" + "--content" "-" + ) + + # Add relays if provided + if [ ${#relays[@]} -gt 0 ]; then + cmd_args+=("${relays[@]}") + fi + + echo "$content" | nak "${cmd_args[@]}" if [ $? -eq 0 ]; then echo "✅ Successfully published: $filename" From 03a7f919616b54779fcfba8203ed185698e0e52d Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 14:47:05 +0100 Subject: [PATCH 04/21] feat: add .env support for RELAYS and NOSTR_SECRET_KEY in publish-markdown script --- .env.example | 13 +++++++++--- .gitignore | 1 + scripts/publish-markdown.sh | 40 +++++++++++++++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index ceaa7546..2e82ac5b 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,10 @@ -# Default article to display on app load -# This should be a valid naddr1... string (NIP-19 encoded address pointer to a kind:30023 long-form article) -VITE_DEFAULT_ARTICLE_NADDR=naddr1qvzqqqr4gupzqmjxss3dld622uu8q25gywum9qtg4w4cv4064jmg20xsac2aam5nqqxnzd3cxqmrzv3exgmr2wfesgsmew +# Nostr configuration for publish-markdown.sh script +# Copy this file to .env and fill in your values + +# Your Nostr secret key (nsec, ncryptsec, or hex format) +# You can also set this via environment variable: export NOSTR_SECRET_KEY=your_key +NOSTR_SECRET_KEY= + +# Space-separated list of relay URLs to publish to +# If not provided, events will be created but not published +RELAYS="ws://localhost:10547 ws://localhost:4869 wss://relay.primal.net wss://wot.dergigi.com wss://relay.dergigi.com wss://nostr.einundzwanzig.space wss://relay.damus.io wss://relay.nostr.bg wss://nos.lol wss://eden.nostr.land" diff --git a/.gitignore b/.gitignore index b99fd766..bba71868 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ applesauce primal-web-app Amber +.env diff --git a/scripts/publish-markdown.sh b/scripts/publish-markdown.sh index a3e85a57..c3f35c0a 100755 --- a/scripts/publish-markdown.sh +++ b/scripts/publish-markdown.sh @@ -12,6 +12,22 @@ set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" MARKDOWN_DIR="$PROJECT_ROOT/test/markdown" +ENV_FILE="$PROJECT_ROOT/.env" + +# Load .env file if it exists +if [ -f "$ENV_FILE" ]; then + # Source the .env file, handling quoted values + set -a # Automatically export all variables + # Use a safe method to load .env that handles quotes + while IFS= read -r line || [ -n "$line" ]; do + # Skip comments and empty lines + [[ "$line" =~ ^[[:space:]]*# ]] && continue + [[ -z "$line" ]] && continue + # Export the variable + export "$line" + done < "$ENV_FILE" + set +a # Stop automatically exporting +fi # Check if nak is installed if ! command -v nak &> /dev/null; then @@ -75,11 +91,18 @@ publish_file() { # Check for NOSTR_SECRET_KEY if [ -z "$NOSTR_SECRET_KEY" ]; then echo "⚠️ Warning: NOSTR_SECRET_KEY environment variable not set" - echo " You can set it with: export NOSTR_SECRET_KEY=your_key_here" + echo " Set it in .env file or with: export NOSTR_SECRET_KEY=your_key_here" echo " Or use --prompt-sec flag (nak will prompt for key)" echo "" fi +# Parse RELAYS from environment if set +default_relays=() +if [ -n "$RELAYS" ]; then + # Split RELAYS string into array + read -ra default_relays <<< "$RELAYS" +fi + # Main logic if [ $# -eq 0 ]; then # No arguments: list all markdown files and let user choose @@ -107,13 +130,21 @@ if [ $# -eq 0 ]; then read -r selection echo "" - echo "Enter relay URLs (space-separated, or press Enter to skip):" + if [ ${#default_relays[@]} -gt 0 ]; then + echo "Enter relay URLs (space-separated, or press Enter to use defaults from .env):" + echo " Defaults: ${default_relays[*]}" + else + echo "Enter relay URLs (space-separated, or press Enter to skip):" + fi read -r relay_input # Parse relay URLs relays=() if [ -n "$relay_input" ]; then read -ra relays <<< "$relay_input" + elif [ ${#default_relays[@]} -gt 0 ]; then + # Use defaults from .env + relays=("${default_relays[@]}") fi if [ "$selection" = "all" ]; then @@ -139,6 +170,11 @@ else shift # Remove filename, rest are relay URLs relays=("$@") + # If no relays provided as arguments, use defaults from .env + if [ ${#relays[@]} -eq 0 ] && [ ${#default_relays[@]} -gt 0 ]; then + relays=("${default_relays[@]}") + fi + # If filename doesn't end with .md, add it if [[ ! "$filename" =~ \.md$ ]]; then filename="${filename}.md" From 142995e83cb511864725d765e1cc3e02e822c504 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 14:47:12 +0100 Subject: [PATCH 05/21] fix: improve .env file parsing to handle quoted values --- scripts/publish-markdown.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/publish-markdown.sh b/scripts/publish-markdown.sh index c3f35c0a..7711c2bf 100755 --- a/scripts/publish-markdown.sh +++ b/scripts/publish-markdown.sh @@ -16,15 +16,18 @@ ENV_FILE="$PROJECT_ROOT/.env" # Load .env file if it exists if [ -f "$ENV_FILE" ]; then - # Source the .env file, handling quoted values + # Source the .env file, handling quoted values properly set -a # Automatically export all variables - # Use a safe method to load .env that handles quotes + # Use eval to properly handle quoted values (safe since we control the file) + # This handles both unquoted and quoted values correctly while IFS= read -r line || [ -n "$line" ]; do # Skip comments and empty lines [[ "$line" =~ ^[[:space:]]*# ]] && continue [[ -z "$line" ]] && continue - # Export the variable - export "$line" + # Remove leading/trailing whitespace + line=$(echo "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') + # Export the variable (handles quoted values) + eval "export $line" done < "$ENV_FILE" set +a # Stop automatically exporting fi From 52be65e382cafc0946d1f1dec4ab572cc396987c Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 14:47:26 +0100 Subject: [PATCH 06/21] chore: remove .env from git tracking, keep .env.example --- .env | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index c46385ff..00000000 --- a/.env +++ /dev/null @@ -1,2 +0,0 @@ -# Default article to display on app load -VITE_DEFAULT_ARTICLE_NADDR=naddr1qvzqqqr4gupzqmjxss3dld622uu8q25gywum9qtg4w4cv4064jmg20xsac2aam5nqqxnzd3cxqmrzv3exgmr2wfesgsmew From a91aa87ef98ea05cdc1cbde4059e2b1e2db5e3fc Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 14:47:49 +0100 Subject: [PATCH 07/21] refactor: move .env file to scripts directory --- scripts/.env.example | 10 ++++++++++ scripts/publish-markdown.sh | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 scripts/.env.example diff --git a/scripts/.env.example b/scripts/.env.example new file mode 100644 index 00000000..2e82ac5b --- /dev/null +++ b/scripts/.env.example @@ -0,0 +1,10 @@ +# Nostr configuration for publish-markdown.sh script +# Copy this file to .env and fill in your values + +# Your Nostr secret key (nsec, ncryptsec, or hex format) +# You can also set this via environment variable: export NOSTR_SECRET_KEY=your_key +NOSTR_SECRET_KEY= + +# Space-separated list of relay URLs to publish to +# If not provided, events will be created but not published +RELAYS="ws://localhost:10547 ws://localhost:4869 wss://relay.primal.net wss://wot.dergigi.com wss://relay.dergigi.com wss://nostr.einundzwanzig.space wss://relay.damus.io wss://relay.nostr.bg wss://nos.lol wss://eden.nostr.land" diff --git a/scripts/publish-markdown.sh b/scripts/publish-markdown.sh index 7711c2bf..75490f36 100755 --- a/scripts/publish-markdown.sh +++ b/scripts/publish-markdown.sh @@ -12,7 +12,7 @@ set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" MARKDOWN_DIR="$PROJECT_ROOT/test/markdown" -ENV_FILE="$PROJECT_ROOT/.env" +ENV_FILE="$SCRIPT_DIR/.env" # Load .env file if it exists if [ -f "$ENV_FILE" ]; then From 453a4f48ca7dbfcfd2be75fe2db9e0d8c6fe5e56 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 14:47:57 +0100 Subject: [PATCH 08/21] refactor: move .env to scripts directory and update documentation --- .env.example | 10 ---------- .gitignore | 1 + scripts/.env.example | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index 2e82ac5b..00000000 --- a/.env.example +++ /dev/null @@ -1,10 +0,0 @@ -# Nostr configuration for publish-markdown.sh script -# Copy this file to .env and fill in your values - -# Your Nostr secret key (nsec, ncryptsec, or hex format) -# You can also set this via environment variable: export NOSTR_SECRET_KEY=your_key -NOSTR_SECRET_KEY= - -# Space-separated list of relay URLs to publish to -# If not provided, events will be created but not published -RELAYS="ws://localhost:10547 ws://localhost:4869 wss://relay.primal.net wss://wot.dergigi.com wss://relay.dergigi.com wss://nostr.einundzwanzig.space wss://relay.damus.io wss://relay.nostr.bg wss://nos.lol wss://eden.nostr.land" diff --git a/.gitignore b/.gitignore index bba71868..adf2ccc7 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ primal-web-app Amber .env +scripts/.env diff --git a/scripts/.env.example b/scripts/.env.example index 2e82ac5b..d5757274 100644 --- a/scripts/.env.example +++ b/scripts/.env.example @@ -1,5 +1,5 @@ # Nostr configuration for publish-markdown.sh script -# Copy this file to .env and fill in your values +# Copy this file to scripts/.env and fill in your values # Your Nostr secret key (nsec, ncryptsec, or hex format) # You can also set this via environment variable: export NOSTR_SECRET_KEY=your_key From 15e91414da7ef58e1ebfd2bb757d9c6052598993 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 14:49:02 +0100 Subject: [PATCH 09/21] feat: add npm script for publishing markdown files --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 312f02d6..8f0baea8 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "dev": "vite", "build": "tsc && vite build", "preview": "vite preview", - "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0" + "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "publish:markdown": "bash scripts/publish-markdown.sh" }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^7.1.0", From 781cade78be5a81b54c120a97523e121c9ec5e64 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 14:49:09 +0100 Subject: [PATCH 10/21] docs: update script usage to include npm command --- scripts/publish-markdown.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/publish-markdown.sh b/scripts/publish-markdown.sh index 75490f36..703aed43 100755 --- a/scripts/publish-markdown.sh +++ b/scripts/publish-markdown.sh @@ -2,6 +2,9 @@ # Script to publish markdown files from test/markdown/ to Nostr using nak # Usage: +# npm run publish:markdown # Interactive mode +# npm run publish:markdown -- tables.md # Publish specific file +# npm run publish:markdown -- tables.md wss://relay.example.com # With relay # ./scripts/publish-markdown.sh [filename] [relay1] [relay2] ... # ./scripts/publish-markdown.sh # Interactive mode # ./scripts/publish-markdown.sh tables.md # Publish specific file @@ -12,7 +15,7 @@ set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" MARKDOWN_DIR="$PROJECT_ROOT/test/markdown" -ENV_FILE="$SCRIPT_DIR/.env" +ENV_FILE="$PROJECT_ROOT/.env" # Load .env file if it exists if [ -f "$ENV_FILE" ]; then From 0ce9f76f3bf694784adae9d77f40e9f4da44dd9c Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 14:53:52 +0100 Subject: [PATCH 11/21] fix: look for .env file in scripts directory instead of project root --- scripts/publish-markdown.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/publish-markdown.sh b/scripts/publish-markdown.sh index 703aed43..75490f36 100755 --- a/scripts/publish-markdown.sh +++ b/scripts/publish-markdown.sh @@ -2,9 +2,6 @@ # Script to publish markdown files from test/markdown/ to Nostr using nak # Usage: -# npm run publish:markdown # Interactive mode -# npm run publish:markdown -- tables.md # Publish specific file -# npm run publish:markdown -- tables.md wss://relay.example.com # With relay # ./scripts/publish-markdown.sh [filename] [relay1] [relay2] ... # ./scripts/publish-markdown.sh # Interactive mode # ./scripts/publish-markdown.sh tables.md # Publish specific file @@ -15,7 +12,7 @@ set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" MARKDOWN_DIR="$PROJECT_ROOT/test/markdown" -ENV_FILE="$PROJECT_ROOT/.env" +ENV_FILE="$SCRIPT_DIR/.env" # Load .env file if it exists if [ -f "$ENV_FILE" ]; then From f6c00f4c205d4442cc46667d86e8a04abc3fd8ff Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 14:56:19 +0100 Subject: [PATCH 12/21] docs: clarify that NOSTR_SECRET_KEY should be a test account key --- .env.example | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..391bf5b5 --- /dev/null +++ b/.env.example @@ -0,0 +1,14 @@ +# Nostr configuration for publish-markdown.sh script +# Copy this file to .env and fill in your values +# +# IMPORTANT: Use a TEST account key for publishing markdown test documents. +# Do not use your main/production Nostr account key here. + +# Your Nostr secret key (nsec, ncryptsec, or hex format) for TEST account +# This is used to publish markdown test files to Nostr +# You can also set this via environment variable: export NOSTR_SECRET_KEY=your_key +NOSTR_SECRET_KEY= + +# Space-separated list of relay URLs to publish to +# If not provided, events will be created but not published +RELAYS="ws://localhost:10547 ws://localhost:4869 wss://relay.primal.net wss://wot.dergigi.com wss://relay.dergigi.com wss://nostr.einundzwanzig.space wss://relay.damus.io wss://relay.nostr.bg wss://nos.lol wss://eden.nostr.land" From 31bcd61aaebf1172c1756237073e18628a4374b1 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 14:58:02 +0100 Subject: [PATCH 13/21] feat: add npm script for publishing test markdown files --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8f0baea8..06f0a1a2 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build": "tsc && vite build", "preview": "vite preview", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "publish:markdown": "bash scripts/publish-markdown.sh" + "publish:test:markdown": "./scripts/publish-markdown.sh" }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^7.1.0", From eaabad98c24496f07668e9f88745d0148b35b5bc Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 15:00:52 +0100 Subject: [PATCH 14/21] fix: use @filename syntax to read markdown content from file instead of stdin --- scripts/publish-markdown.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/publish-markdown.sh b/scripts/publish-markdown.sh index 75490f36..ba237499 100755 --- a/scripts/publish-markdown.sh +++ b/scripts/publish-markdown.sh @@ -12,7 +12,7 @@ set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" MARKDOWN_DIR="$PROJECT_ROOT/test/markdown" -ENV_FILE="$SCRIPT_DIR/.env" +ENV_FILE="$PROJECT_ROOT/.env" # Load .env file if it exists if [ -f "$ENV_FILE" ]; then @@ -50,11 +50,8 @@ publish_file() { echo "📝 Publishing: $filename" echo " Identifier: $identifier" - # Read the markdown content - local content=$(cat "$file_path") - # Extract title from first H1 if available, otherwise use filename - local title=$(echo "$content" | grep -m 1 "^# " | sed 's/^# //' || echo "$identifier") + local title=$(grep -m 1 "^# " "$file_path" | sed 's/^# //' || echo "$identifier") # Add relays if provided if [ ${#relays[@]} -gt 0 ]; then @@ -68,12 +65,13 @@ publish_file() { # The "d" tag is required for replaceable events (kind 30023) # Using the filename (without extension) as the identifier # Build command array to avoid eval issues + # Use @filename syntax to read content from file (nak supports this) local cmd_args=( "event" "-k" "30023" "-d" "$identifier" "-t" "title=\"$title\"" - "--content" "-" + "--content" "@$file_path" ) # Add relays if provided @@ -81,7 +79,7 @@ publish_file() { cmd_args+=("${relays[@]}") fi - echo "$content" | nak "${cmd_args[@]}" + nak "${cmd_args[@]}" if [ $? -eq 0 ]; then echo "✅ Successfully published: $filename" From 48213fa5841c460f3d596a17612e91b3309b645c Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 15:04:03 +0100 Subject: [PATCH 15/21] style: add subtle table styling that matches app theme - Add comprehensive table styles with borders, padding, and spacing - Style table headers with elevated background - Add subtle row striping for better readability - Support text alignment (left, center, right) - Maintain mobile responsiveness with horizontal scrolling - Use theme CSS variables for consistent theming across light/dark modes --- src/styles/components/reader.css | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/styles/components/reader.css b/src/styles/components/reader.css index 76cd34ed..40d4c2e9 100644 --- a/src/styles/components/reader.css +++ b/src/styles/components/reader.css @@ -170,6 +170,49 @@ .reader-html pre { background: var(--color-bg-subtle); border: 1px solid var(--color-border); border-radius: 8px; padding: 1rem; overflow-x: auto; margin: 1rem 0; font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace; } .reader-html code { background: var(--color-bg-subtle); border: 1px solid var(--color-border); border-radius: 4px; padding: 0.15rem 0.4rem; font-size: 0.9em; font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace; } .reader-html pre code { background: transparent; border: none; padding: 0; display: block; } +/* Tables - subtle styling that matches the app theme */ +.reader-markdown table, .reader-html table { + width: 100%; + border-collapse: collapse; + margin: 1.5rem 0; + border: 1px solid var(--color-border); + border-radius: 8px; + overflow: hidden; + background: var(--color-bg); +} +.reader-markdown thead, .reader-html thead { + background: var(--color-bg-elevated); +} +.reader-markdown th, .reader-html th { + padding: 0.75rem 1rem; + text-align: left; + font-weight: 600; + color: var(--color-text); + border-bottom: 2px solid var(--color-border); + font-size: 0.95em; +} +.reader-markdown td, .reader-html td { + padding: 0.75rem 1rem; + border-bottom: 1px solid var(--color-border-subtle); + color: var(--color-text); + vertical-align: top; +} +.reader-markdown tbody tr:last-child td, .reader-html tbody tr:last-child td { + border-bottom: none; +} +/* Subtle row striping for better readability */ +.reader-markdown tbody tr:nth-child(even), .reader-html tbody tr:nth-child(even) { + background: var(--color-bg-subtle); +} +/* Table alignment support */ +.reader-markdown th[align="center"], .reader-html th[align="center"], +.reader-markdown td[align="center"], .reader-html td[align="center"] { + text-align: center; +} +.reader-markdown th[align="right"], .reader-html th[align="right"], +.reader-markdown td[align="right"], .reader-html td[align="right"] { + text-align: right; +} /* Mobile: prevent code blocks from causing horizontal overflow */ @media (max-width: 768px) { .reader-markdown pre, .reader-html pre { @@ -190,6 +233,12 @@ display: block; max-width: 100%; overflow-x: auto; + -webkit-overflow-scrolling: touch; + } + /* Reduce padding on mobile for better fit */ + .reader-markdown table td, .reader-html table td, + .reader-markdown table th, .reader-html table th { + padding: 0.5rem 0.75rem; } .reader-markdown img, .reader-html img { From 4fd8a0b18f3ae5df99688c367f4381a5d49e57bc Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 15:06:46 +0100 Subject: [PATCH 16/21] test: extend table with numbers to 21 rows - Add rows 4-21 with decreasing scores - Test table styling with longer content --- test/markdown/tables.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/markdown/tables.md b/test/markdown/tables.md index d3658a3c..3919c655 100644 --- a/test/markdown/tables.md +++ b/test/markdown/tables.md @@ -74,6 +74,24 @@ This file contains various markdown table examples to test table parsing and ren | 1 | Alice | 95 | 95% | | 2 | Bob | 87 | 87% | | 3 | Charlie | 82 | 82% | +| 4 | David | 78 | 78% | +| 5 | Emma | 75 | 75% | +| 6 | Frank | 72 | 72% | +| 7 | Grace | 70 | 70% | +| 8 | Henry | 68 | 68% | +| 9 | Ivy | 65 | 65% | +| 10 | Jack | 63 | 63% | +| 11 | Kate | 60 | 60% | +| 12 | Liam | 58 | 58% | +| 13 | Mia | 55 | 55% | +| 14 | Noah | 53 | 53% | +| 15 | Olivia | 50 | 50% | +| 16 | Paul | 48 | 48% | +| 17 | Quinn | 45 | 45% | +| 18 | Ryan | 43 | 43% | +| 19 | Sarah | 40 | 40% | +| 20 | Tom | 38 | 38% | +| 21 | Uma | 35 | 35% | ## Table with Special Characters From 2089208448ba5b4b9e8261e6f76b32c9e565c12b Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 15:08:15 +0100 Subject: [PATCH 17/21] docs: add explanatory paragraphs to each test table - Add descriptive text before each table explaining what it tests - Improve documentation for table test cases - Help developers understand the purpose of each test scenario --- test/markdown/tables.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/markdown/tables.md b/test/markdown/tables.md index 3919c655..c2905826 100644 --- a/test/markdown/tables.md +++ b/test/markdown/tables.md @@ -4,6 +4,8 @@ This file contains various markdown table examples to test table parsing and ren ## Basic Table +This is a simple two-column table with two data rows. It tests basic table structure and rendering without any special formatting or alignment. + | Column 1 | Column 2 | | ------------- | ------------- | | Cell 1, Row 1 | Cell 2, Row 1 | @@ -11,6 +13,8 @@ This file contains various markdown table examples to test table parsing and ren ## Table with Alignment +This table demonstrates text alignment options in markdown tables. The first column is left-aligned (default), the second is centered using `:---:`, and the third is right-aligned using `---:`. This tests that the CSS alignment rules work correctly. + | Left | Centered | Right | | :----------- | :--------------: | -------------------------: | | This is left | Text is centered | And this is right-aligned | @@ -18,6 +22,8 @@ This file contains various markdown table examples to test table parsing and ren ## Table with Formatting +This table contains various markdown formatting within cells: italic text using asterisks, bold text using double asterisks, and inline code using backticks. This tests that formatting is preserved and rendered correctly within table cells. + | Name | Location | Food | | ------- | ------------ | ------- | | *Alice* | **New York** | `Pizza` | @@ -25,6 +31,8 @@ This file contains various markdown table examples to test table parsing and ren ## Table with Links +This table includes markdown links within cells. It tests that hyperlinks are properly rendered and clickable within table cells, and that link styling matches the app's theme. + | Name | Website | Description | | ----- | -------------------------- | --------------------- | | Alice | [GitHub](https://github.com) | Code repository | @@ -32,6 +40,8 @@ This file contains various markdown table examples to test table parsing and ren ## Table with Code Blocks +This table contains inline code examples in cells. It tests that code formatting (monospace font, background, borders) is properly applied within table cells and doesn't conflict with table styling. + | Language | Example | | -------- | -------------------------- | | Python | `print("Hello, World!")` | @@ -40,6 +50,8 @@ This file contains various markdown table examples to test table parsing and ren ## Wide Table (Testing Horizontal Scroll) +This table has eight columns to test horizontal scrolling behavior on mobile devices and smaller screens. The table should allow users to scroll horizontally to view all columns while maintaining proper styling and readability. + | Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 | Column 7 | Column 8 | | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | | Data 1 | Data 2 | Data 3 | Data 4 | Data 5 | Data 6 | Data 7 | Data 8 | @@ -47,6 +59,8 @@ This file contains various markdown table examples to test table parsing and ren ## Table with Mixed Content +This table combines various content types: currency values, emoji indicators, and descriptive text. It tests how different content types render together within table cells and ensures proper spacing and alignment. + | Item | Price | Status | Notes | | ---- | ----- | ------ | ------------------------------ | | Apple | $1.00 | ✅ In stock | Fresh from the farm | @@ -55,6 +69,8 @@ This file contains various markdown table examples to test table parsing and ren ## Table with Empty Cells +This table contains empty cells to test how the table styling handles missing data. Empty cells should still maintain proper borders and spacing, ensuring the table structure remains intact. + | Name | Email | Phone | | ---- | ----- | ----- | | Alice | alice@example.com | | @@ -63,12 +79,16 @@ This file contains various markdown table examples to test table parsing and ren ## Table with Long Text +This table tests text wrapping behavior with varying column widths. The third column contains a long paragraph that should wrap to multiple lines within the cell while maintaining proper padding and readability. This is especially important for responsive design. + | Short | Medium Length Column | Very Long Column That Contains A Lot Of Text And Should Wrap Properly | | ----- | -------------------- | -------------------------------------------------------------------- | | A | This is medium text | This is a very long piece of text that should wrap to multiple lines when displayed in the table cell. It should maintain proper formatting and readability. | ## Table with Numbers +This table contains 21 rows of ranked data with numeric scores and percentages. It's useful for testing row striping, scrolling behavior with longer tables, and ensuring that numeric alignment and formatting remain consistent throughout a larger dataset. + | Rank | Name | Score | Percentage | | ---- | ---- | ----- | ---------- | | 1 | Alice | 95 | 95% | @@ -95,6 +115,8 @@ This file contains various markdown table examples to test table parsing and ren ## Table with Special Characters +This table contains escaped special characters that have meaning in markdown syntax. It tests that these characters are properly escaped and displayed as literal characters rather than being interpreted as markdown syntax. + | Symbol | Name | Usage | | ------ | ---- | ----- | | `\|` | Pipe | Used in markdown tables | @@ -103,11 +125,15 @@ This file contains various markdown table examples to test table parsing and ren ## Table with Headers Only +This table contains only header rows with no data rows. It tests edge case handling for tables without content, ensuring that the header styling is still applied correctly even when there's no body content. + | Header 1 | Header 2 | Header 3 | | -------- | -------- | -------- | ## Single Column Table +This is a minimal table with only one column. It tests how table styling handles narrow tables and ensures that single-column layouts are properly formatted with appropriate borders and spacing. + | Item | | ---- | | First | @@ -116,6 +142,8 @@ This file contains various markdown table examples to test table parsing and ren ## Table with Nested Formatting +This table demonstrates complex nested formatting combinations within cells, including bold and italic text together, code blocks containing links, and strikethrough text. It tests that multiple formatting types can coexist properly within table cells. + | Description | Example | | ----------- | ------- | | Bold and italic | ***Important*** | From ed93675d8dc7bc6c07a5e518ee88d8c00b902517 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 15:12:58 +0100 Subject: [PATCH 18/21] chore: remove misplaced .env.example from scripts directory The publish-markdown.sh script expects .env in the project root, not in scripts/, so this example file was in the wrong location. --- scripts/.env.example | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 scripts/.env.example diff --git a/scripts/.env.example b/scripts/.env.example deleted file mode 100644 index d5757274..00000000 --- a/scripts/.env.example +++ /dev/null @@ -1,10 +0,0 @@ -# Nostr configuration for publish-markdown.sh script -# Copy this file to scripts/.env and fill in your values - -# Your Nostr secret key (nsec, ncryptsec, or hex format) -# You can also set this via environment variable: export NOSTR_SECRET_KEY=your_key -NOSTR_SECRET_KEY= - -# Space-separated list of relay URLs to publish to -# If not provided, events will be created but not published -RELAYS="ws://localhost:10547 ws://localhost:4869 wss://relay.primal.net wss://wot.dergigi.com wss://relay.dergigi.com wss://nostr.einundzwanzig.space wss://relay.damus.io wss://relay.nostr.bg wss://nos.lol wss://eden.nostr.land" From 024e62118b261032e92352299e19b3b5c2a77e92 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 15:13:46 +0100 Subject: [PATCH 19/21] docs: add test account npub and profile link to publish-markdown.sh Add documentation about the test account used for publishing markdown test documents, including the npub and profile link to Marky Markdown Testerson's writings. --- scripts/publish-markdown.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/publish-markdown.sh b/scripts/publish-markdown.sh index ba237499..e1530088 100755 --- a/scripts/publish-markdown.sh +++ b/scripts/publish-markdown.sh @@ -6,6 +6,15 @@ # ./scripts/publish-markdown.sh # Interactive mode # ./scripts/publish-markdown.sh tables.md # Publish specific file # ./scripts/publish-markdown.sh tables.md wss://relay.example.com # With relay +# +# Environment: +# The script reads .env from the project root directory ($PROJECT_ROOT/.env) +# Required: NOSTR_SECRET_KEY (your nsec, ncryptsec, or hex format key) +# Optional: RELAYS (space-separated list of relay URLs) +# +# Test account for markdown test documents: +# npub: npub1marky39a9qmadyuux9lr49pdhy3ddxrdwtmd9y957kye66qyu3vq7spdm2 +# Profile: https://read.withboris.com/p/npub1marky39a9qmadyuux9lr49pdhy3ddxrdwtmd9y957kye66qyu3vq7spdm2/writings set -e From d76bfb66bbfdefbfbd58cf43e964dd2b3763f903 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 15:14:31 +0100 Subject: [PATCH 20/21] docs: add test account npub and profile link to .env.example Add documentation about the test account used for publishing markdown test documents, including the npub and profile link to Marky Markdown Testerson's writings. --- .env.example | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 391bf5b5..dc079178 100644 --- a/.env.example +++ b/.env.example @@ -1,14 +1,14 @@ # Nostr configuration for publish-markdown.sh script # Copy this file to .env and fill in your values -# -# IMPORTANT: Use a TEST account key for publishing markdown test documents. -# Do not use your main/production Nostr account key here. -# Your Nostr secret key (nsec, ncryptsec, or hex format) for TEST account -# This is used to publish markdown test files to Nostr +# Your Nostr secret key (nsec, ncryptsec, or hex format) # You can also set this via environment variable: export NOSTR_SECRET_KEY=your_key NOSTR_SECRET_KEY= # Space-separated list of relay URLs to publish to # If not provided, events will be created but not published RELAYS="ws://localhost:10547 ws://localhost:4869 wss://relay.primal.net wss://wot.dergigi.com wss://relay.dergigi.com wss://nostr.einundzwanzig.space wss://relay.damus.io wss://relay.nostr.bg wss://nos.lol wss://eden.nostr.land" + +# Test account used for publishing markdown test documents: +# npub: npub1marky39a9qmadyuux9lr49pdhy3ddxrdwtmd9y957kye66qyu3vq7spdm2 +# Profile: https://read.withboris.com/p/npub1marky39a9qmadyuux9lr49pdhy3ddxrdwtmd9y957kye66qyu3vq7spdm2/writings From e7e02dd12987a6fd5c8f1e152f15574422eeb349 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 7 Nov 2025 15:16:45 +0100 Subject: [PATCH 21/21] fix: remove quotation marks from title in publish-markdown script --- scripts/publish-markdown.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish-markdown.sh b/scripts/publish-markdown.sh index e1530088..d7686140 100755 --- a/scripts/publish-markdown.sh +++ b/scripts/publish-markdown.sh @@ -79,7 +79,7 @@ publish_file() { "event" "-k" "30023" "-d" "$identifier" - "-t" "title=\"$title\"" + "-t" "title=$title" "--content" "@$file_path" )