Open RokeJulianLockhart opened 11 months ago
Using https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-toolsai/vsextensions/jupyter-renderers/1.0.17/vspackage, inserting a YAML preamble into a Markdown section of a Jupyter Notebook should render the YAML metadata at the top of the markdown section. Instead, this extension does not activate:
```.IPYNB { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "# `{\"origin\": \"HTTPS://cran.R-Project.org/web/packages/ymlthis/vignettes/yaml-fieldguide.html\"}`{.JSON}\n", "\n", "title: \"Comprehensive Review of Functional Apparel\" # `{\"to_do\": \"\"}`{.JSON}\n", "subject: \"Attributes constituting functional apparel.\" # `{\"to_do\": \"\"}`{.JSON}\n", "description: \"The uses, use cases, intended functions, advantages, and disadvantages of the attributes constituting functional apparel, and the types of functional apparel incorporating them.\" # `{\"to_do\": \"\"}`{.JSON}\n", "lang: \"eng-GBR-oxendict\" # `{\"information\": \"\"}`{.JSON} `{\"to_do\": \"Ascertain where `en-GB-oxendict` is from.\"}`{.JSON}\n", "date: \"`r format(Sys.Date())`\" # `{\"to_do\": \"HTTPS://StackOverflow.com/a/29518651/9731176\"}`{.JSON}\n", "author: # `{\"information\": \"specifies authors\"}`{.JSON}\n", " - name: \"[`{third: \\\"Beedell\\\", first: \\\"Roke\\\"}`{.JSON5}](HTTPS://wim.nl.TAB.Digital/apps/contacts/All%20contacts/e1f2ec5c-074e-4875-ac62-53ff24770ffa~contacts)\"\n", " affiliation: [\"NA\"] # `{\"information\": \"This refers to organizations.\"}`{.JSON}\n", " email: \"mailTo:s4skzs+s4refp@RokeJulianLockhart.AnonAddy.com\" # `{\"origin\": \"HTTPS://app.Addy.IO/aliases//edit\"}`{.JSON}\n", "output: # `{\"information\": \"Spcifies additional document output formats in Pandoc.\"}`{.JSON}\n", " - html_document: # `{\"information\": \"Enables `.HTML` document output in Pandoc.\"}`{.JSON}\n", " toc: true # `{\"information\": \"`true` enables the table of contents.\"}`{.JSON}\n", " toc_depth: 6 # `{\"information\": \"6 is the maximum.\"}`{.JSON}\n", " number_sections: true # `{\"information\": \"Numbers sections at each table header.\"}`{.JSON}\n", "---\n", "\n", "# **AnonAddy Alias Generator**\n", "\n", "1.\t## **Manual**\n", "\n", "\tCopy into [the Aliases list](https://app.anonaddy.com/).\n", "\n", "\t```md\n", "\t`{\"status\": \"unknown\", \"origin\": {\"URI\": \"\", \"instructions\": \"\"}}`{.JSON}\n", "\t```\n", "\n", "1.\t## **Automatic**\n", "\n", "\t1. [ ] Automatically upload to AnonAddy and use aforestated format." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "vscode": { "languageId": "powershell" } }, "outputs": [], "source": [ "#!/usr/bin/env -S tea pwsh-preview\n", "\n", "#Requires -PSEdition Core\n", "#Requires -Version 7.2\n", "\n", "<#\n", "\n", "\t.DESCRIPTION\n", "\tSwitch (Get-Culture | Select-Object -ExpandProperty Name)\n", "\t{\n", "\t\t'En-US' {$LocalizedOutput = 'This converts values between bases.'}\n", "\t\t'En-GB' {$LocalizedOutput = 'This converts values between bases.'}\n", "\t}\n", "\n", "\t.INPUTS\n", "\tSwitch (Get-Culture | Select-Object -ExpandProperty Name)\n", "\t{\n", "\t\t'En-US' {$LocalizedOutput = ''}\n", "\t\t'En-GB' {$LocalizedOutput = ''}\n", "\t}\n", "\n", "#>\n", "\n", "Function New-AnonAddyAlias {\n", "\n", "\t$Name = (Get-PSCallStack)[0].Command\n", "\n", "\t# Set-StrictMode -Version 2 # @toDo Use https://stackoverflow.com/a/51430382/9731176 to remediate \"The variable '$ResultNumber' cannot be retrieved because it has not been set.\"\n", "\n", "\t#$VerbosePreference = \"SilentlyContinue\"\n", "\t#$DebugPreference = 'SilentlyContinue'\n", "\t$VerbosePreference = 'Continue'\n", "\t$DebugPreference = 'Continue'\n", "\n", "\t. \"$PSScriptRoot/numerical_base_converter/code/(Convert-Base).txt.ps1\" # @toDo Compartmentalize getting unix epoch into common library as `Get-UnixEpoch` (https://stackoverflow.com/a/14882447/9731176)\n", "\n", "\t$Preferences = @{\n", "\t\tBaseUserInput = 36\n", "\t\tWaitTimeUserInput = 1\n", "\t}\n", "\n", "\tFunction Set-PreferenceValue {\n", "\n", "\t\tParam (\n", "\t\t\t[Parameter(\n", "\t\t\t\tMandatory = $True,\n", "\t\t\t\tPosition = 0)]\n", "\t\t\t[System.Object] $Preference)\n", "\n", "\t\t$Context = \"'$Preference' will be overwriten by '$([Environment]::UserName)' in current session. Its current value is $Preferences[`\"$Preference`\"]\"\n", "\t\t$Question = 'Are you sure you want to proceed?'\n", "\n", "\t\t# @origin https://stackoverflow.com/questions/24649019/how-to-use-confirm-in-powershell#comment99530557_24649481\n", "\t\t$Decision = $Host.UI.PromptForChoice(\n", "\t\t\t\"$Context\",\n", "\t\t\t\"$Question\",\n", "\t\t\t@('&Yes'; '&No'), 1)\n", "\n", "\t\t$UserInputValue = Read-Host -Prompt \"Enter the new value for '$Preference'\"\n", "\t\tIf ($Decision -Eq 1) { $Preferences[\"$Preference\"] = $UserInputValue }\n", "\t}\n", "\n", "\t# @info iterates over all preferences, asking whether they should be changed for this session\n", "\t$MaximumCount = ($Preferences.Count)\n", "\tFor ($Repeat = 0; $Repeat -LT $MaximumCount; $Repeat++) {\n", "\t\tSet-PreferenceValue -Preference $Preferences[\"$Repeat\"]\n", "\t}\n", "\n", "\tFunction New-BaseEncodedUNIXEpochTimestamp {\n", "\n", "\t\tParam (\n", "\t\t\t[Parameter(\n", "\t\t\t\tMandatory = $True,\n", "\t\t\t\tPosition = 0)]\n", "\t\t\t[int] $Base)\n", "\n", "\t\t$TimesInvoked += 1\n", "\t\t$Name = (Get-PSCallStack)[0].Command\n", "\t\tWrite-Debug \"Times '$Name' invoked: '$TimesInvoked'\" | Out-Host\n", "\n", "\t\tConvertTo-NumeralBase -Number (\n", "\t\t\t(New-TimeSpan -Start (\n", "\t\t\t\tGet-Date `\n", "\t\t\t\t\t-Year 1970 `\n", "\t\t\t\t\t-Month 01 `\n", "\t\t\t\t\t-Day 01 `\n", "\t\t\t\t\t-Hour 00 `\n", "\t\t\t\t\t-Minute 00 `\n", "\t\t\t\t\t-Second 00).ToUniversalTime() `\n", "\t\t\t\t-End (Get-Date)).TotalSeconds) `\n", "\t\t\t-Base $Base\n", "\t}\n", "\n", "\tWrite-Debug \"$(New-BaseEncodedUNIXEpochTimestamp -Base $BaseUserInput)\" | Out-Host\n", "\n", "\tFunction New-BaseEncodedEMailAddress {\n", "\n", "\t\tParam (\n", "\t\t\t[Parameter(\n", "\t\t\t\tMandatory = $True,\n", "\t\t\t\tPosition = 0)]\n", "\t\t\t[int] $Base,\n", "\t\t\t[Parameter(\n", "\t\t\t\tMandatory = $True,\n", "\t\t\t\tPosition = 0)]\n", "\t\t\t[int] $WaitTime,\n", "\t\t\t[Parameter(\n", "\t\t\t\tMandatory = $True,\n", "\t\t\t\tPosition = 1)]\n", "\t\t\t[string] $Domain)\n", "\n", "\t\t$Name = (Get-PSCallStack)[0].Command\n", "\t\tWrite-Debug \"Times '$Name' invoked: '$TimesInvoked'\" | Out-Host\n", "\t\t$TimesInvoked += 1\n", "\t\tWrite-Debug \"Times '$Name' invoked: '$TimesInvoked'\" | Out-Host\n", "\n", "\t\tIf ($TimesInvoked -Eq 1) { $Script:Address = \"$(New-BaseEncodedUNIXEpochTimestamp -Base $BaseUserInput)\" }\n", "\t\t$Script:SubAddress = \"$(\n", "\t\t\tWrite-Debug \"Waited $WaitTime seconds to differentiate between alias and sub address.\" | Out-Host # @toDo Ascertain how to output this directly to the display rather than through the pipeline.\n", "\t\t\tStart-Sleep -Seconds $WaitTime\n", "\t\t\tNew-BaseEncodedUNIXEpochTimestamp -Base $BaseUserInput)\"\n", "\n", "\t\t# @toDo https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/format-table?view=powershell-7.3#example-5-use-properties-for-table-output\n", "\t\tWrite-Debug \"Inside '$Name', '`$Script:Address' is '$Script:Address'.\" | Out-Host # @toDo https://stackoverflow.com/questions/38697164/is-it-possible-to-print-variable-names#comment102710637_58161277\n", "\t\tWrite-Debug \"Inside '$Name', '`$Script:SubAddress' is '$Script:SubAddress'.\" | Out-Host # @toDo https://stackoverflow.com/questions/38697164/is-it-possible-to-print-variable-names#comment102710637_58161277\n", "\n", "\t\t$NewAnonaddyAddress = \"$Script:Address+$Script:SubAddress\"\n", "\t\tWrite-Verbose \"The new alias is '$NewAnonaddyAddress'.\" | Out-Host\n", "\n", "\t\tReturn \"$Script:Address+$Script:SubAddress@$Domain\"\n", "\t}\n", "\n", "\t$AnonAddyAddresses = $Null # @info Prevents too many values when executing commands independently in shell.\n", "\tFor ($Repeat = 0; $Repeat -LT 2; $Repeat++) {\n", "\t\t$Name = '20230711T010348'\n", "\t\t$AnonAddyAddresses += @(\"$(New-BaseEncodedEMailAddress -Base $BaseUserInput -Domain 'rokejulianlockhart.anonaddy.com' -WaitTime $WaitTimeUserInput)\")\n", "\t\t$TimesInvoked += 1\n", "\t\tWrite-Debug \"$(\"Address $Repeat is \" + [String]$AnonAddyAddresses[$Repeat])\" | Out-Host\n", "\t\tWrite-Debug \"Times '$Name' invoked: '$TimesInvoked'\" | Out-Host\n", "\t}\n", "\n", "\tWrite-Debug \"`$Script:Address is '$Script:Address'.\" | Out-Host # @toDo https://stackoverflow.com/questions/38697164/is-it-possible-to-print-variable-names#comment102710637_58161277\n", "\tWrite-Debug \"`$Script:SubAddress is '$Script:SubAddress'.\" | Out-Host # @toDo https://stackoverflow.com/questions/38697164/is-it-possible-to-print-variable-names#comment102710637_58161277\n", "\n", "\t$Position = 0\n", "\tWrite-Debug \"Address '$Position' is '$($AnonAddyAddresses[$Position])'\" | Out-Host\n", "\t$AnonAddyAddresses[$Position] | Set-Clipboard\n", "\n", "\t$MaximumCount = ($AnonAddyAddresses.Count) # @info https://www.reddit.com/r/PowerShell/comments/da5lbu/comment/f1nep90/?utm_source=share&utm_medium=web2x&context=3\n", "\tFor ($Repeat = 0; $Repeat -LT $MaximumCount; $Repeat++) {\n", "\t\t$Name = '20230711T011218'\n", "\t\tWrite-Debug \"'`$Repeat' is '$Repeat'\" | Out-Host\n", "\t\tIf ($Repeat -Eq 0) { Write-Output \"$($AnonAddyAddresses[$Repeat]) is the registered alias.\" | Out-Host }\n", "\t\tWrite-Output \"$($AnonAddyAddresses[$Repeat]) has been copied to your clipboard.\" | Out-Host\n", "\t\tRead-Host -Prompt \"Press enter to $(\n", "\t\t\tIf ($Repeat -Eq ($MaximumCount - 1)) {'exit the program'}\n", "\t\t\tElse {\"copy '$($AnonAddyAddresses[$($Repeat + 1)])'\"})\"\n", "\t}\n", "\n", "\t# @toDo ask the user whether to create a new AnonAddy address\n", "\t# @info https://app.anonaddy.com/docs/#\n", "\n", "} New-AnonAddyAlias" ] } ], "metadata": { "language_info": { "name": "python" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 } ```
Using https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-toolsai/vsextensions/jupyter-renderers/1.0.17/vspackage, inserting a YAML preamble into a Markdown section of a Jupyter Notebook should render the YAML metadata at the top of the markdown section. Instead, this extension does not activate: