diff --git a/.gitignore b/.gitignore
index cbd461d2102..1044d8cf962 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,6 @@ built
/phpcs.xml
/phpunit.xml
/*.sql
+
+# Generated via bin/transform-readme.php
+/readme.txt
diff --git a/Gruntfile.js b/Gruntfile.js
index a5bbf0f3335..234f73c4bed 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -10,7 +10,6 @@ module.exports = function( grunt ) {
'assets',
'back-compat',
'includes',
- 'README.md',
'src',
'templates',
'vendor',
@@ -71,6 +70,9 @@ module.exports = function( grunt ) {
stdout: true,
stderr: true,
},
+ transform_readme: {
+ command: 'php bin/transform-readme.php',
+ },
verify_matching_versions: {
command: 'php bin/verify-version-consistency.php',
},
@@ -147,6 +149,9 @@ module.exports = function( grunt ) {
return true;
} );
+ grunt.task.run( 'shell:transform_readme' );
+ paths.push( 'readme.txt' );
+
paths.push( 'composer.*' ); // Copy in order to be able to do run composer_install.
paths.push( 'assets/js/**/*.js' );
paths.push( 'assets/js/**/*.asset.php' );
diff --git a/README.md b/README.md
index 7080dd0a801..4435e631072 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,17 @@
-# AMP
+# AMP Plugin for WordPress
-Contributors: google, xwp, automattic, westonruter, albertomedina, schlessera, swissspidy, pierlo, johnwatkins0, joshuawold, ryankienstra
-Tags: amp, mobile, optimization, accelerated mobile pages, framework, components, blocks, performance, ux, seo, official
-Requires at least: 4.9
-Tested up to: 5.6
-Stable tag: 2.0.10
-License: GPLv2 or later
-License URI: http://www.gnu.org/licenses/gpl-2.0.html
-Requires PHP: 5.6
-
-![The Official AMP Plugin for WordPress](.wordpress-org/banner-1544x500.png)
+![Banner](.wordpress-org/banner-1544x500.png)
The official AMP Plugin, supported by the AMP team. Formerly Accelerated Mobile Pages, AMP enables great experiences across both mobile and desktop.
+**Contributors:** [google](https://profiles.wordpress.org/google), [xwp](https://profiles.wordpress.org/xwp), [automattic](https://profiles.wordpress.org/automattic), [westonruter](https://profiles.wordpress.org/westonruter), [albertomedina](https://profiles.wordpress.org/albertomedina), [schlessera](https://profiles.wordpress.org/schlessera), [swissspidy](https://profiles.wordpress.org/swissspidy), [pierlo](https://profiles.wordpress.org/pierlo), [johnwatkins0](https://profiles.wordpress.org/johnwatkins0), [joshuawold](https://profiles.wordpress.org/joshuawold), [ryankienstra](https://profiles.wordpress.org/ryankienstra)
+**Tags:** [amp](https://wordpress.org/plugins/tags/amp), [mobile](https://wordpress.org/plugins/tags/mobile), [optimization](https://wordpress.org/plugins/tags/optimization), [accelerated mobile pages](https://wordpress.org/plugins/tags/accelerated-mobile-pages), [framework](https://wordpress.org/plugins/tags/framework), [components](https://wordpress.org/plugins/tags/components), [blocks](https://wordpress.org/plugins/tags/blocks), [performance](https://wordpress.org/plugins/tags/performance), [ux](https://wordpress.org/plugins/tags/ux), [seo](https://wordpress.org/plugins/tags/seo), [official](https://wordpress.org/plugins/tags/official)
+**Requires at least:** 4.9
+**Tested up to:** 5.6
+**Stable tag:** 2.0.10
+**License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html)
+**Requires PHP:** 5.6
+
[![Build Status](https://github.com/ampproject/amp-wp/workflows/Build,%20test%20&%20measure/badge.svg)](https://github.com/ampproject/amp-wp/actions?query=branch%3Adevelop+workflow%3A%22Build%2C+test+%26+measure%22)
[![Coverage Status](https://img.shields.io/codecov/c/github/ampproject/amp-wp/develop.svg)](https://codecov.io/gh/ampproject/amp-wp)
[![Built with Grunt](https://gruntjs.com/cdn/builtwith.svg)](http://gruntjs.com)
@@ -21,11 +20,11 @@ The official AMP Plugin, supported by the AMP team. Formerly Accelerated Mobile
This official plugin from the AMP project enables AMP content publishing with WordPress in a way that is fully and seamlessly integrated with the standard mechanisms of the platform.
-https://www.youtube.com/watch?v=s52JNMT59s8&list=PLXTOW_XMsIDRGRr5QDffrvND8Qh1RndFb
+[![Play video on YouTube](https://i1.ytimg.com/vi/s52JNMT59s8/hqdefault.jpg)](https://www.youtube.com/watch?v=s52JNMT59s8&list=PLXTOW_XMsIDRGRr5QDffrvND8Qh1RndFb)
For more videos like this, check out the ongoing [AMP for WordPress video series](https://www.youtube.com/playlist?list=PLXTOW_XMsIDRGRr5QDffrvND8Qh1RndFb).
-The key features are the following:
+The plugin's key features include:
1. **Automate the process of generating AMP-valid markup as much as possible**, letting users follow the standard workflows they are used to in WordPress.
2. **Provide effective validation tools** to help users deal with AMP incompatibilities when they happen, including mechanisms for **identifying**, **contextualizing**, and **resolving issues caused by validation errors**.
@@ -88,17 +87,29 @@ Please see the [FAQs on amp-wp.org](https://amp-wp.org/documentation/frequently-
## Screenshots
-1. New onboarding wizard to help you get started.
![New onboarding wizard to help you get started.](.wordpress-org/screenshot-1.png)
+### New onboarding wizard to help you get started.
+
+![New onboarding wizard to help you get started.](.wordpress-org/screenshot-1.png)
+
+### Built for developers and non-technical content creators alike.
+
+![Built for developers and non-technical content creators alike.](.wordpress-org/screenshot-2.png)
+
+### Theme selection to enhance the Reader mode experience.
+
+![Theme selection to enhance the Reader mode experience.](.wordpress-org/screenshot-3.png)
+
+### Preview how your site looks across desktop and mobile before finalising changes.
-2. Built for developers and non-technical content creators alike.
![Built for developers and non-technical content creators alike.](.wordpress-org/screenshot-2.png)
+![Preview how your site looks across desktop and mobile before finalising changes.](.wordpress-org/screenshot-4.png)
-3. Theme selection to enhance the Reader mode experience.
![Theme selection to enhance the Reader mode experience.](.wordpress-org/screenshot-3.png)
+### Customize the design of AMP pages in the Customizer.
-4. Preview how your site looks across desktop and mobile before finalising changes.
![Preview how your site looks across desktop and mobile before finalising changes.](.wordpress-org/screenshot-4.png)
+![Customize the design of AMP pages in the Customizer.](.wordpress-org/screenshot-5.png)
-5. Customize the design of AMP pages in the Customizer.
![Customize the design of AMP pages in the Customizer.](.wordpress-org/screenshot-5.png)
+### Reopen the onboarding wizard, change individual options, or manage advanced settings.
-6. Reopen the onboarding wizard, change individual options, or manage advanced settings.
![Reopen the onboarding wizard, change individual options, or manage advanced settings.](.wordpress-org/screenshot-6.png)
+![Reopen the onboarding wizard, change individual options, or manage advanced settings.](.wordpress-org/screenshot-6.png)
## Changelog
diff --git a/bin/transform-readme.php b/bin/transform-readme.php
new file mode 100755
index 00000000000..6e9350e7829
--- /dev/null
+++ b/bin/transform-readme.php
@@ -0,0 +1,178 @@
+#!/usr/bin/env php
+ 150 ) {
+ fwrite( STDERR, "The short description is too long: $description\n" );
+ exit( __LINE__ );
+ }
+
+ $metadata = [];
+ foreach ( explode( "\n", $parts[2] ) as $meta ) {
+ $meta = trim( $meta );
+ if ( ! preg_match( '/^\*\*(?P.+?):\*\* (?P.+)/', $meta, $matches ) ) {
+ fwrite( STDERR, "Parse error for meta line: $meta.\n" );
+ exit( __LINE__ );
+ }
+
+ $unlinked_value = preg_replace( '/\[(.+?)]\(.+?\)/', '$1', $matches['value'] );
+
+ $metadata[ $matches['key'] ] = $unlinked_value;
+
+ // Extract License URI from link.
+ if ( 'License' === $matches['key'] ) {
+ $license_uri = preg_replace( '/\[.+?]\((.+?)\)/', '$1', $matches['value'] );
+
+ if ( 0 !== strpos( $license_uri, 'http' ) ) {
+ fwrite( STDERR, "Unable to extract License URI from: $meta.\n" );
+ exit( __LINE__ );
+ }
+
+ $metadata['License URI'] = $license_uri;
+ }
+ }
+
+ $expected_metadata = [
+ 'Contributors',
+ 'Tags',
+ 'Requires at least',
+ 'Tested up to',
+ 'Stable tag',
+ 'License',
+ 'License URI',
+ 'Requires PHP',
+ ];
+ foreach ( $expected_metadata as $key ) {
+ if ( empty( $metadata[ $key ] ) ) {
+ fwrite( STDERR, "Failed to parse metadata. Missing: $key\n" );
+ exit( __LINE__ );
+ }
+ }
+
+ $replaced = "$header\n";
+ foreach ( $metadata as $key => $value ) {
+ $replaced .= "$key: $value\n";
+ }
+ $replaced .= "\n$description\n\n";
+
+ return $replaced;
+ },
+ $readme_txt
+);
+
+// Replace image-linked YouTube videos with bare URLs.
+$readme_txt = preg_replace(
+ '#\[!\[.+?]\(.+?\)]\((https://www\.youtube\.com/.+?)\)#',
+ '$1',
+ $readme_txt
+);
+
+// Fix up the screenshots.
+$screenshots_captioned = 0;
+$readme_txt = preg_replace_callback(
+ '/(?<=## Screenshots\n\n)(.+?)(?=## Changelog)/s',
+ static function ( $matches ) use ( &$screenshots_captioned ) {
+ if ( ! preg_match_all( '/### (.+)/', $matches[0], $screenshot_matches ) ) {
+ fwrite( STDERR, "Unable to parse screenshot headings.\n" );
+ exit( __LINE__ );
+ }
+
+ $screenshot_txt = '';
+ foreach ( $screenshot_matches[1] as $i => $screenshot_caption ) {
+ $screenshot_txt .= sprintf( "%d. %s\n", $i + 1, $screenshot_caption );
+ $screenshots_captioned++;
+ }
+ $screenshot_txt .= "\n";
+
+ return $screenshot_txt;
+ },
+ $readme_txt,
+ 1,
+ $replace_count
+);
+if ( 0 === $replace_count ) {
+ fwrite( STDERR, "Unable to transform screenshots.\n" );
+ exit( __LINE__ );
+}
+
+$screenshot_files = glob( __DIR__ . '/../.wordpress-org/screenshot-*' );
+if ( count( $screenshot_files ) !== $screenshots_captioned ) {
+ fwrite( STDERR, "Number of screenshot files does not match number of screenshot captions.\n" );
+ exit( __LINE__ );
+}
+foreach ( $screenshot_files as $i => $screenshot_file ) {
+ if ( 0 !== strpos( basename( $screenshot_file ), sprintf( 'screenshot-%d.', $i + 1 ) ) ) {
+ fwrite( STDERR, "Screenshot filename is not sequential: $screenshot_file.\n" );
+ exit( __LINE__ );
+ }
+}
+
+// Convert markdown headings into WP readme headings for good measure.
+$readme_txt = preg_replace_callback(
+ '/^(#+)\s(.+)/m',
+ static function ( $matches ) {
+ $md_heading_level = strlen( $matches[1] );
+ $heading_text = $matches[2];
+
+ // #: ===
+ // ##: ==
+ // ###: =
+ $txt_heading_level = 4 - $md_heading_level;
+ if ( $txt_heading_level <= 0 ) {
+ fwrite( STDERR, "Heading too small to transform: {$matches[0]}.\n" );
+ exit( __LINE__ );
+ }
+
+ return sprintf(
+ '%1$s %2$s %1$s',
+ str_repeat( '=', $txt_heading_level ),
+ $heading_text
+ );
+ },
+ $readme_txt,
+ -1,
+ $replace_count
+);
+if ( 0 === $replace_count ) {
+ fwrite( STDERR, "Unable to transform headings.\n" );
+ exit( __LINE__ );
+}
+
+if ( ! file_put_contents( __DIR__ . '/../readme.txt', $readme_txt ) ) {
+ fwrite( STDERR, "Failed to write readme.txt.\n" );
+ exit( __LINE__ );
+}
+
+fwrite( STDOUT, "Validated README.md and generated readme.txt\n" );
diff --git a/bin/verify-version-consistency.php b/bin/verify-version-consistency.php
index 635358ecf03..0b9a0dc0bad 100755
--- a/bin/verify-version-consistency.php
+++ b/bin/verify-version-consistency.php
@@ -15,7 +15,7 @@
$versions = [];
$readme_md = file_get_contents( dirname( __FILE__ ) . '/../README.md' );
-if ( ! preg_match( '/Stable tag:\s+(?P\S+)/i', $readme_md, $matches ) ) {
+if ( ! preg_match( '/\*\*Stable tag:\*\*\s+(?P\S+)/i', $readme_md, $matches ) ) {
echo "Could not find stable tag in readme\n";
exit( 1 );
}