diff --git a/.gitignore b/.gitignore index cb1a652..6448a84 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ php-markdown-1.0.1n.zip /php-markdown-lib-1.6.0.zip /php-markdown-lib-1.7.0.zip /php-markdown-lib-1.8.0.zip +/php-markdown-1.8.0-01ab082.tgz diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..6b1993d --- /dev/null +++ b/composer.json @@ -0,0 +1,26 @@ +{ + "name": "michelf/php-markdown", + "type": "library", + "description": "PHP Markdown", + "homepage": "https://michelf.ca/projects/php-markdown/", + "keywords": ["markdown"], + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Michel Fortin", + "email": "michel.fortin@michelf.ca", + "homepage": "https://michelf.ca/", + "role": "Developer" + }, + { + "name": "John Gruber", + "homepage": "https://daringfireball.net/" + } + ], + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "psr-4": { "Michelf\\": "Michelf/" } + } +} diff --git a/makesrc.sh b/makesrc.sh new file mode 100755 index 0000000..87d223d --- /dev/null +++ b/makesrc.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +NAME=$(basename $PWD) +OWNER=$(sed -n '/^%global gh_owner/{s/.* //;p}' $NAME.spec) +PROJECT=$(sed -n '/^%global gh_project/{s/.* //;p}' $NAME.spec) +VERSION=$(sed -n '/^Version:/{s/.* //;p}' $NAME.spec) +COMMIT=$(sed -n '/^%global gh_commit/{s/.* //;p}' $NAME.spec) +SHORT=${COMMIT:0:7} + +echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION\n" + +echo "Cloning..." +rm -rf $PROJECT-$COMMIT +git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT + +echo "Getting commit..." +pushd $PROJECT-$COMMIT +git checkout $COMMIT +cp composer.json ../composer.json +popd + +echo "Archiving..." +tar czf $NAME-$VERSION-$SHORT.tgz --exclude .git $PROJECT-$COMMIT + +echo "Cleaning..." +rm -rf $PROJECT-$COMMIT + +echo "Done." diff --git a/php-markdown-php74.patch b/php-markdown-php74.patch new file mode 100644 index 0000000..fb6d782 --- /dev/null +++ b/php-markdown-php74.patch @@ -0,0 +1,137 @@ +diff -up Michelf/MarkdownExtra.php.php74 Michelf/MarkdownExtra.php +--- Michelf/MarkdownExtra.php.php74 2019-07-26 15:03:52.000000000 +0200 ++++ Michelf/MarkdownExtra.php 2019-07-26 15:07:25.255088870 +0200 +@@ -212,9 +212,9 @@ class MarkdownExtra extends \Michelf\Mar + $attributes = array(); + $id = false; + foreach ($elements as $element) { +- if ($element{0} == '.') { ++ if ($element[0] == '.') { + $classes[] = substr($element, 1); +- } else if ($element{0} == '#') { ++ } else if ($element[0] == '#') { + if ($id === false) $id = substr($element, 1); + } else if (strpos($element, '=') > 0) { + $parts = explode('=', $element, 2); +@@ -508,14 +508,14 @@ class MarkdownExtra extends \Michelf\Mar + } + } + // Check for: Indented code block. +- else if ($tag{0} == "\n" || $tag{0} == " ") { ++ else if ($tag[0] == "\n" || $tag[0] == " ") { + // Indented code block: pass it unchanged, will be handled + // later. + $parsed .= $tag; + } + // Check for: Code span marker + // Note: need to check this after backtick fenced code blocks +- else if ($tag{0} == "`") { ++ else if ($tag[0] == "`") { + // Find corresponding end marker. + $tag_re = preg_quote($tag); + if (preg_match('{^(?>.+?|\n(?!\n))*?(?clean_tags_re . ')\b}', $tag) || +- $tag{1} == '!' || $tag{1} == '?') ++ $tag[1] == '!' || $tag[1] == '?') + { + // Need to parse tag and following text using the HTML parser. + // (don't check for markdown attribute) +@@ -564,7 +564,7 @@ class MarkdownExtra extends \Michelf\Mar + preg_match('{^) + // Comments and Processing Instructions. + if (preg_match('{^auto_close_tags_re . ')\b}', $tag) || +- $tag{1} == '!' || $tag{1} == '?') ++ $tag[1] == '!' || $tag[1] == '?') + { + // Just add the tag to the block as if it was text. + $block_text .= $tag; +@@ -683,7 +683,7 @@ class MarkdownExtra extends \Michelf\Mar + // Increase/decrease nested tag count. Only do so if + // the tag's name match base tag's. + if (preg_match('{^header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null; + +@@ -1466,7 +1466,7 @@ class MarkdownExtra extends \Michelf\Mar + + $classes = array(); + if ($classname != "") { +- if ($classname{0} == '.') ++ if ($classname[0] == '.') + $classname = substr($classname, 1); + $classes[] = $this->code_class_prefix . $classname; + } +diff -up Michelf/Markdown.php.php74 Michelf/Markdown.php +--- Michelf/Markdown.php.php74 2019-07-26 15:03:52.000000000 +0200 ++++ Michelf/Markdown.php 2019-07-26 15:06:27.924736197 +0200 +@@ -952,7 +952,7 @@ class Markdown implements MarkdownInterf + return $matches[0]; + } + +- $level = $matches[2]{0} == '=' ? 1 : 2; ++ $level = $matches[2][0] == '=' ? 1 : 2; + + // ID attribute generation + $idAtt = $this->_generateIdFromHeaderValue($matches[1]); +@@ -1358,7 +1358,7 @@ class Markdown implements MarkdownInterf + } else { + // Other closing marker: close one em or strong and + // change current token state to match the other +- $token_stack[0] = str_repeat($token{0}, 3-$token_len); ++ $token_stack[0] = str_repeat($token[0], 3-$token_len); + $tag = $token_len == 2 ? "strong" : "em"; + $span = $text_stack[0]; + $span = $this->runSpanGamut($span); +@@ -1383,7 +1383,7 @@ class Markdown implements MarkdownInterf + } else { + // Reached opening three-char emphasis marker. Push on token + // stack; will be handled by the special condition above. +- $em = $token{0}; ++ $em = $token[0]; + $strong = "$em$em"; + array_unshift($token_stack, $token); + array_unshift($text_stack, ''); +@@ -1796,9 +1796,9 @@ class Markdown implements MarkdownInterf + * @return string + */ + protected function handleSpanToken($token, &$str) { +- switch ($token{0}) { ++ switch ($token[0]) { + case "\\": +- return $this->hashPart("&#". ord($token{1}). ";"); ++ return $this->hashPart("&#". ord($token[1]). ";"); + case "`": + // Search for end marker in remaining text. + if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm', diff --git a/php-markdown.spec b/php-markdown.spec index 981dc18..74e492e 100644 --- a/php-markdown.spec +++ b/php-markdown.spec @@ -5,19 +5,22 @@ # # Please preserve changelog entries # - -# We still provide the classic library, for now -%global classic_version 1.0.2 +%global gh_commit 01ab082b355bf188d907b9929cd99b2923053495 +%global gh_short %(c=%{gh_commit}; echo ${c:0:7}) +%global gh_owner michelf +%global gh_project php-markdown Name: php-markdown Version: 1.8.0 -Release: 5%{?dist} +Release: 6%{?dist} Summary: Markdown implementation in PHP License: BSD URL: https://michelf.ca/projects/php-markdown/ -Source0: http://littoral.michelf.ca/code/php-markdown/%{name}-lib-%{version}.zip -Source1: http://littoral.michelf.ca/code/php-markdown/%{name}-%{classic_version}.zip +Source0: %{name}-%{version}-%{gh_short}.tgz +Source1: makesrc.sh + +Patch0: php-markdown-php74.patch BuildArch: noarch BuildRequires: php-fedora-autoloader-devel @@ -42,21 +45,14 @@ Autoloader: %{_datadir}/php/Michelf/markdown-autoload.php %prep -%setup -q -n 'PHP Markdown Lib %{version}' -a 1 - -# documentation and licenses -mkdir -p library lic/library -mv Readme.* composer.json library -mv License.* lic/library +%setup -q -n %{gh_project}-%{gh_commit} +%patch0 -p0 -mkdir -p classic lic/classic -cd "PHP Markdown %{classic_version}" -mv License.text ../lic/classic -mv "PHP Markdown Readme.text" ../classic/Readme.text +mv License.md LICENSE %build -# Generate simple autoloader +: Generate simple autoloader %{_bindir}/phpab \ --template fedora \ --output Michelf/markdown-autoload.php \ @@ -70,9 +66,6 @@ install -d %{buildroot}%{_datadir}/php/ # PSR-0 library cp -pr Michelf %{buildroot}%{_datadir}/php/Michelf -# Old classic -install -p -m 644 "PHP Markdown %{classic_version}/markdown.php" %{buildroot}%{_datadir}/php/ - %check php -r ' @@ -85,15 +78,20 @@ require_once "%{buildroot}%{_datadir}/php/Michelf/markdown-autoload.php"; %files %{!?_licensedir:%global license %%doc} -%license lic/* -%doc library classic -# Classic version -%{_datadir}/php/markdown.php +%license LICENSE +%doc composer.json +%doc *.md # Library version %{_datadir}/php/Michelf %changelog +* Fri Jul 26 2019 Remi Collet - 1.8.0-6 +- drop old classic version +- use git snapshot as next version will have test suite +- add patch for PHP 7.4, adapted for 1.8.0 from + https://github.com/michelf/php-markdown/pull/316 + * Fri Jul 26 2019 Fedora Release Engineering - 1.8.0-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild diff --git a/sources b/sources index ebec71d..9a22b1b 100644 --- a/sources +++ b/sources @@ -1,2 +1 @@ -SHA512 (php-markdown-1.0.2.zip) = b876cd3196a532f28f9a942ec04bcc0766bc804f9f2918291109943847117c5532dce0f06ad9ae535efa55de57d88a8a4a9537c3bb47ef104c3901c014604dfa -SHA512 (php-markdown-lib-1.8.0.zip) = 2b38d52f10cc74abfb787c1d01237fca6c4da9e4681e9c2999d70af7100a4759d45c73a5dff4b48f5d237d3e0c9aec4f918593e7dfb4517ca73c7ec12429b523 +SHA512 (php-markdown-1.8.0-01ab082.tgz) = dd2fca98761db35e6fe13be681199056d1173095f87a6cfb2eb62626b246a6dc3c41252ec47ca1bf5be11957d5dfa41dfd288ab181e2075db47c0acc9ab855e1