Skip to content

Commit 9259e5b

Browse files
committed
chore: track vendor/scrivo/ in git, update build script to copy bundled dependencies
Update .gitignore to include vendor/scrivo/ (highlight.php) while excluding other vendor packages. Replace composer install in build-zip.sh with explicit rsync of bundled runtime dependencies, excluding dev-only files. Map 'text' language to 'none' in server-side block rendering for consistency with client-side mode.
1 parent 86e280f commit 9259e5b

302 files changed

Lines changed: 35060 additions & 7 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
/vendor/
1+
# Ignore entire vendor except bundled runtime packages
2+
/vendor/*
3+
!/vendor/scrivo/
24
/node_modules/
35
/phpcompat-tools/
46
/build/

build-zip.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,21 @@ CLAUDE.md
5151
AGENTS.md
5252
EOF
5353

54-
# Install production-only PHP dependencies into the build copy.
55-
# composer.json/lock are excluded from rsync, so copy them temporarily.
56-
echo "Installing production PHP dependencies..."
57-
cp composer.json composer.lock "$TEMP_DIR/"
58-
composer install --working-dir="$TEMP_DIR" --no-dev --quiet
59-
rm "$TEMP_DIR/composer.json" "$TEMP_DIR/composer.lock"
54+
# Copy required vendor dependencies (everything in vendor/ is excluded above,
55+
# so production runtime deps must be copied back in explicitly). Dev-only files
56+
# such as .github workflow folders are stripped from the copies.
57+
echo "Copying vendor dependencies..."
58+
mkdir -p "$TEMP_DIR/vendor"
59+
60+
# highlight.php (server-side syntax highlighter; loaded via its own PSR-0
61+
# autoloader, not the Composer autoloader).
62+
if [ -d "vendor/scrivo/highlight.php" ]; then
63+
mkdir -p "$TEMP_DIR/vendor/scrivo"
64+
rsync -a --exclude='.github' --exclude='.git*' --exclude='README.md' --exclude='CONTRIBUTING.md' --exclude='AUTHORS.txt' --exclude='.php-cs-fixer.dist.php' vendor/scrivo/highlight.php "$TEMP_DIR/vendor/scrivo/"
65+
else
66+
echo "Error: vendor/scrivo/highlight.php directory not found. Run 'composer install' first." >&2
67+
exit 1
68+
fi
6069

6170
# Create zip
6271
echo "Creating zip file..."

includes/frontend/class-blocks.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,16 @@ protected function render_code_block_server( string $block_content, array $param
433433
$highlight_lines = $params['highlight_lines'];
434434
$max_height = $params['max_height'];
435435

436+
// 'text' is stored as the block attribute value but there is no 'text'
437+
// grammar. Map it to 'none' so plain text blocks get consistent class
438+
// names with the client-side mode. Replace in the saved HTML (which
439+
// already carries language-text on both <pre> and <code>) rather than
440+
// appending.
441+
if ( 'text' === $language ) {
442+
$block_content = str_replace( 'language-text', 'language-none', $block_content );
443+
$language = '';
444+
}
445+
436446
// ── Extract raw code from saved HTML ──────────────────────────────────
437447
if ( ! preg_match( '/<code[^>]*>([\s\S]*?)<\/code>/i', $block_content, $m ) ) {
438448
return $block_content;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in('demo')
5+
->in('Highlight')
6+
->in('HighlightUtilities')
7+
->in('test')
8+
->in('tools')
9+
->exclude('lib_dojo')
10+
->exclude('lib_highlight')
11+
;
12+
13+
$config = new PhpCsFixer\Config();
14+
return $config
15+
->setRules([
16+
'@PSR1' => true,
17+
'@PSR2' => true,
18+
'@Symfony' => true,
19+
'array_indentation' => true,
20+
'array_syntax' => ['syntax' => 'long'],
21+
'concat_space' => ['spacing' => 'one'],
22+
'echo_tag_syntax' => ['format' => 'short'],
23+
'no_alias_language_construct_call' => false,
24+
'no_alternative_syntax' => false,
25+
'no_useless_else' => true,
26+
'no_useless_return' => true,
27+
'phpdoc_align' => true,
28+
'phpdoc_order' => true,
29+
'phpdoc_trim_consecutive_blank_line_separation' => true,
30+
'single_quote' => false,
31+
'ternary_to_null_coalescing' => false,
32+
'trailing_comma_in_multiline' => true,
33+
'visibility_required' => false,
34+
'yoda_style' => [
35+
'equal' => false,
36+
'identical' => false,
37+
],
38+
])
39+
->setFinder($finder)
40+
;

0 commit comments

Comments
 (0)