private void writeScript() throws SAXException {
        //don't write an attached macro if there is no content
        //we may want to revisit this behavior
        if (script.toString().isBlank()) {
            return;
        }
        //do anything with attrs?
        Metadata m = new Metadata();
        m.set(TikaCoreProperties.EMBEDDED_RESOURCE_TYPE,
                TikaCoreProperties.EmbeddedResourceType.MACRO.toString());
        String src = scriptAtts.getValue("src");
        if (src != null) {
            m.set(HTML.SCRIPT_SOURCE, src);
        }

        EmbeddedDocumentExtractor embeddedDocumentExtractor =
                EmbeddedDocumentUtil.getEmbeddedDocumentExtractor(context);
        //try to scrape dataURISchemes from javascript
        List<DataURIScheme> dataURISchemes = dataURISchemeUtil.extract(script.toString());
        for (DataURIScheme dataURIScheme : dataURISchemes) {
            Metadata dataUriMetadata = new Metadata();
            dataUriMetadata.set(TikaCoreProperties.EMBEDDED_RESOURCE_TYPE,
                    TikaCoreProperties.EmbeddedResourceType.INLINE.toString());
            dataUriMetadata.set(Metadata.CONTENT_TYPE, dataURIScheme.getMediaType().toString());
            if (embeddedDocumentExtractor.shouldParseEmbedded(dataUriMetadata)) {
                try (TikaInputStream tis = TikaInputStream.get(dataURIScheme.getInputStream())) {
                    embeddedDocumentExtractor
                            .parseEmbedded(tis, xhtml, dataUriMetadata, true);
                } catch (IOException e) {
                    //swallow
                }
            }
        }

        try (TikaInputStream tis = TikaInputStream.get(script.toString().getBytes(StandardCharsets.UTF_8))) {
            embeddedDocumentExtractor.parseEmbedded(tis, xhtml, m, true);
        } catch (IOException e) {
            //shouldn't ever happen
        } finally {
            script.setLength(0);
        }
    }
Adds a metadata setting from the HTML <head/> to the Tika metadata
object. The name and value are normalized where possible.
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-html-module/src/main/java/org/apache/tika/parser/html/HtmlHandler.java