1#!/bin/sh
2# Copyright 2020-2023 The Khronos Group Inc.
3#
4# SPDX-License-Identifier: Apache-2.0
5
6# Replace marker comments in asciidoctor-generated HTML with JavaScript
7# and HTML supporting the searchbox.
8#
9# The marker comments are inserted by config/loadable_html/extension.rb,
10# and are a stable place to add these comments, unlike the previous
11# method of using 'patch'. That could fail when moving to new
12# asciidoctor versions and style files. This can still fail, but should
13# be more robust.
14#
15# Usage: addscripts.sh input-file output-file
16
17# Find path to the script, which is also the patch to the replacements
18path=`dirname $0`
19
20input=$1
21output=$2
22test -f $input || (echo "No input file $1" ; exit 1)
23
24# Replace the first marker comment with text in addscript.jsmarker
25# Replace the second marker comment with text in addscript.searchboxmarker
26
27cp $input $output
28sed -i -e '/<\!--ChunkedSearchJSMarker-->/r '"$path/addscript.jsmarker" \
29       -e '/<\!--ChunkedSearchboxMarker-->/r '"$path/addscript.searchboxmarker" \
30       $output
31