diff --git a/_includes/head.html b/_includes/head.html new file mode 100644 index 0000000000..899e96e446 --- /dev/null +++ b/_includes/head.html @@ -0,0 +1,11 @@ +
+ + + + {%- seo -%} + + {%- feed_meta -%} + {%- if jekyll.environment == 'production' and site.google_analytics -%} + {%- include google-analytics.html -%} + {%- endif -%} + diff --git a/_includes/specials/bech32/05-fee-savings.md b/_includes/specials/bech32/05-fee-savings.md index 992a02e077..d6e6b62c6e 100644 --- a/_includes/specials/bech32/05-fee-savings.md +++ b/_includes/specials/bech32/05-fee-savings.md @@ -1,3 +1,4 @@ +{% auto_anchor %} One reason your users and customers may want you to implement bech32 sending support is because it'll allow the receivers of those payments to save on fees when they re-spend that money. This week, we'll look at @@ -60,3 +61,4 @@ relay fee). This means more people spending native segwit inputs lowers the fee not just for those spenders but for everyone who creates transactions---including wallets and services that support sending to bech32 addresses. +{% endauto_anchor %} diff --git a/_includes/specials/bech32/06-stackexchange.md b/_includes/specials/bech32/06-stackexchange.md index 709c5a2805..8a60ed7009 100644 --- a/_includes/specials/bech32/06-stackexchange.md +++ b/_includes/specials/bech32/06-stackexchange.md @@ -1,3 +1,4 @@ +{% auto_anchor %} This week we look at some of the [top-voted bech32 questions and answers][top bech32 qa] from the Bitcoin StackExchange. This includes everything since bech32 was first announced about two years ago. @@ -39,3 +40,4 @@ everything since bech32 was first announced about two years ago. [bech32 easy]: {{news38}}#bech32-sending-support [top bech32 qa]: https://bitcoin.stackexchange.com/search?tab=votes&q=bech32 [bech32 adoption]: https://en.bitcoin.it/wiki/Bech32_adoption +{% endauto_anchor %} diff --git a/_includes/specials/bech32/07-altbech32.md b/_includes/specials/bech32/07-altbech32.md index 524e77971a..9908db7798 100644 --- a/_includes/specials/bech32/07-altbech32.md +++ b/_includes/specials/bech32/07-altbech32.md @@ -1,3 +1,4 @@ +{% auto_anchor %} It's said that "imitation is the most sincere form of flattery." In this week's section, we take a quick look at a few other systems that are using variations on bech32. If you're already going to need to @@ -48,3 +49,4 @@ probably worth your time to implement it for Bitcoin too. [blockstream liquid]: https://blockstream.com/liquid/ [confidential assets]: https://elementsproject.org/features/confidential-transactions [blech32 py]: https://github.com/ElementsProject/elements/commit/9cb2fa051fcbe0fe66f15e6b88d224d1935376f4#diff-265badc7e18059096c32a61b0eada470 +{% endauto_anchor %} diff --git a/_includes/specials/bech32/11-only-bech32.md b/_includes/specials/bech32/11-only-bech32.md index f3b2ac788a..85596166b4 100644 --- a/_includes/specials/bech32/11-only-bech32.md +++ b/_includes/specials/bech32/11-only-bech32.md @@ -1,3 +1,4 @@ +{% auto_anchor %} [Last week][Newsletter #47], we described one of the costs of not upgrading to bech32 sending support---users might think your service is out-of-date and so look for alternative services. This week, we'll look @@ -61,3 +62,4 @@ their preferred wallet. [trust wallet]: https://trustwallet.com/ [electrum]: https://electrum.org/ [news45 bech32]: {{news45}}#bech32-sending-support +{% endauto_anchor %} diff --git a/_includes/specials/bech32/12-midway.md b/_includes/specials/bech32/12-midway.md index 79b9128b29..f0e6063f4b 100644 --- a/_includes/specials/bech32/12-midway.md +++ b/_includes/specials/bech32/12-midway.md @@ -1,3 +1,4 @@ +{% auto_anchor %} This segment marks half-way through our series about bech32, so we decided to have some fun this week by describing some bech32-related trivia that's interesting but not important enough for its own segment. @@ -29,3 +30,4 @@ interesting but not important enough for its own segment. [cpu time]: https://youtu.be/NqiN9VFE4CU?t=1329 [wikipedia bch]: https://en.wikipedia.org/wiki/BCH_code [first plans]:https://blog.bitmain.com/en/uahf-contingency-plan-uasf-bip148/ +{% endauto_anchor %} diff --git a/_includes/specials/bech32/21-brd.md b/_includes/specials/bech32/21-brd.md index f7a6bc4b84..c3b2fde348 100644 --- a/_includes/specials/bech32/21-brd.md +++ b/_includes/specials/bech32/21-brd.md @@ -1,3 +1,4 @@ +{% auto_anchor %} *The following case study contributed by Optech member company [BRD][] describes what they learned implementing bech32 and other segwit technology for their wallet.* @@ -81,3 +82,4 @@ fees are still relatively low. [identical spk data]: /en/bech32-sending-support/#sending-to-a-legacy-address [bech32 future]: /en/bech32-sending-support/#automatic-bech32-support-for-future-soft-forks [whensegwit]: https://whensegwit.com/ +{% endauto_anchor %} diff --git a/_includes/specials/bech32/23-compat.md b/_includes/specials/bech32/23-compat.md index d5f5cf131c..0c6799ede6 100644 --- a/_includes/specials/bech32/23-compat.md +++ b/_includes/specials/bech32/23-compat.md @@ -1,4 +1,4 @@ -As of this writing, here are what we think are some of the most +{% auto_anchor %}As of this writing, here are what we think are some of the most significant bech32-related insights we've gleaned from creating and reviewing the [Compatibility Matrix][]. @@ -40,3 +40,4 @@ reviewing the [Compatibility Matrix][]. of change output to the type of payment output) but, in most cases, this seems like a missed opportunity for wallets to send change to their own bech32 addresses for increased fee savings. +{% endauto_anchor %} diff --git a/_includes/specials/taproot/en/01-single-sig.md b/_includes/specials/taproot/en/01-single-sig.md index 3b205179a5..931c29afc2 100644 --- a/_includes/specials/taproot/en/01-single-sig.md +++ b/_includes/specials/taproot/en/01-single-sig.md @@ -1,3 +1,4 @@ +{% auto_anchor %} Using Optech's [transaction size calculator][], we can compare the sizes of different types of single-sig transactions. As expected, transactions using P2WPKH inputs and outputs are much smaller than those @@ -73,3 +74,4 @@ for single-sigs, both for wallet users and for the network as a whole. [news3 sig size]: /en/newsletters/2018/07/10/#unrelayable-transactions [news101 fee overpayment attack]: /en/newsletters/2020/06/10/#fee-overpayment-attack-on-multi-input-segwit-transactions [batch graph]: https://github.com/jonasnick/secp256k1/blob/schnorrsig-batch-verify/doc/speedup-batch.md +{% endauto_anchor %} diff --git a/_includes/specials/taproot/en/02-descriptors.md b/_includes/specials/taproot/en/02-descriptors.md index 55734f4f27..0de2b1f882 100644 --- a/_includes/specials/taproot/en/02-descriptors.md +++ b/_includes/specials/taproot/en/02-descriptors.md @@ -1,3 +1,4 @@ +{% auto_anchor %} [Output script descriptors][topic descriptors] provide a generic way for wallets to store the information needed to create addresses, efficiently scan for outputs paying those addresses, and later spend from those @@ -97,3 +98,4 @@ using more advanced taproot features later. {% include linkers/issues.md issues="22051" %} [bip341 safety]: https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_note-22 +{% endauto_anchor %} diff --git a/_includes/specials/taproot/en/03-p2wpkh-to-p2tr.md b/_includes/specials/taproot/en/03-p2wpkh-to-p2tr.md index 6b17e071d7..01063c5078 100644 --- a/_includes/specials/taproot/en/03-p2wpkh-to-p2tr.md +++ b/_includes/specials/taproot/en/03-p2wpkh-to-p2tr.md @@ -1,3 +1,4 @@ +{% auto_anchor %} For wallets that already support receiving and spending v0 segwit P2WPKH outputs, upgrading to v1 segwit P2TR for single-sig should be easy. Here are the main steps: @@ -117,3 +118,4 @@ pages of the Bitcoin Wiki so other developers can learn from your code. [bip341 sigmsg]: https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#common-signature-message [wiki bech32 adoption]: https://en.bitcoin.it/wiki/Bech32_adoption [wiki taproot uses]: https://en.bitcoin.it/wiki/Taproot_Uses +{% endauto_anchor %} diff --git a/_includes/specials/taproot/en/04-why-wait.md b/_includes/specials/taproot/en/04-why-wait.md index be50d9d969..d526f99a09 100644 --- a/_includes/specials/taproot/en/04-why-wait.md +++ b/_includes/specials/taproot/en/04-why-wait.md @@ -12,6 +12,7 @@ Not tested: {% assign safe_trb = "709,776" %} {% endcapture %} +{% auto_anchor %} Earlier entries in this series saw us encouraging developers working on wallets and services to begin implementing [taproot][topic taproot] @@ -76,3 +77,4 @@ None of the above changes the advice given in the [first part][taproot [news139 st]: /en/newsletters/2021/03/10/#taproot-activation-discussion [taproot series 1]: /en/preparing-for-taproot/#bech32m-sending-support +{% endauto_anchor %} diff --git a/_includes/specials/taproot/en/05-taproot-notebooks.md b/_includes/specials/taproot/en/05-taproot-notebooks.md index 4b7fb1b3b3..225f105138 100644 --- a/_includes/specials/taproot/en/05-taproot-notebooks.md +++ b/_includes/specials/taproot/en/05-taproot-notebooks.md @@ -1,3 +1,4 @@ +{% auto_anchor %} Almost two years ago, James Chiang and Elichai Turkel produced an [open source repository][taproot-workshop] of Jupyter notebooks for a series of Optech workshops to train developers on [taproot][topic taproot] technology. @@ -53,3 +54,4 @@ taken the time to learn from them earlier. [workshops]: /en/schorr-taproot-workshop/ [notebooks #168]: https://github.com/bitcoinops/taproot-workshop/pull/168 [mouton tweet]: https://twitter.com/ElleMouton/status/1418108253096095745 +{% endauto_anchor %} diff --git a/_plugins/auto-anchor.rb b/_plugins/auto-anchor.rb index d380301344..445aafc471 100644 --- a/_plugins/auto-anchor.rb +++ b/_plugins/auto-anchor.rb @@ -7,11 +7,8 @@ # - [Summary][]: Details # - [Summary](URL): Details -Jekyll::Hooks.register :documents, :pre_render do |post| - ## Don't process documents if YAML headers say: "auto_id: false" or - ## we're formatting for email - unless post.data["auto_id"] == false || ENV['JEKYLL_ENV'] == 'email' - post.content.gsub!(/^ *- .*/) do |string| +def auto_anchor(content) + content.gsub!(/^ *- .*/) do |string| ## Find shortest match for **bold**, *italics*, or [markdown][links] title = string.match(/\*\*.*?\*\*|\*.*?\*|\[.*?\][(\[]/).to_s @@ -27,5 +24,31 @@ string.sub!(/-/, id_prefix) end end +end + +## Run automatically on all documents +Jekyll::Hooks.register :documents, :pre_render do |post| + ## Don't process documents if YAML headers say: "auto_id: false" or + ## we're formatting for email + unless post.data["auto_id"] == false || ENV['JEKYLL_ENV'] == 'email' + auto_anchor(post.content) + end +end + +## Block filter that provides {% auto_anchor %}{% endauto_anchor %} for +## use on {% include %} files +module Jekyll + class RenderAutoAnchor < Liquid::Block + + def render(context) + text = super + text = auto_anchor(text) + text = Liquid::Template.parse(text) + text.render(@context) + end + end end + +Liquid::Template.register_tag('auto_anchor', Jekyll::RenderAutoAnchor) +