-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Pass options to all transforms
- Loading branch information
Showing
10 changed files
with
129 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<template> | ||
<article> | ||
<h1>Clara Campoamor Rodríguez</h1> | ||
<h2>Early days</h2> | ||
Clara Campoamor Rodríguez was born on 12 February 1888 in Madrid, Spain to a working-class | ||
family, she began working as a seamstress at age 13, but continued to study part-time on the | ||
side, eventually seeking to pass the test that would guarantee her entry into law school. In the | ||
interim, she worked her way up through a number of government positions, first with the Post | ||
Office in San Sebastián in 1909, then as a typing teacher back in Madrid in 1914. | ||
<h2>Political debut</h2> | ||
In addition to her job as a teacher, Campoamor became involved in the Madrid political scene | ||
through a second job as a journalist at the newspaper La Tribuna, where she got in touch with | ||
influential feminine figures of the time, such as Carmen de Burgos and Eva Nelken. These | ||
acquaintances led Clara Campoamor to join and collaborate with various feminist associations and | ||
to write political commentary. | ||
<h2>Law practice</h2> | ||
After successfully passing the law school entrance exam and entering the University of Madrid | ||
School of Law, Campoamor continued to work multiple jobs until she earned her degree in 1924, | ||
aged 36, and entered legal practice. Campoamor was the second woman to ever incorporate the | ||
Madrid Bar Association, the first one to defend a case before the Spanish High Court, and one of | ||
the first to represent Spain in the League of Nations. Her private practice specialized in | ||
issues affecting women, including paternity cases and marital law. Campoamor successfully | ||
advocated in 1927 for improvements to the child labor laws and electoral law changes. When it | ||
became legal for women to run for the Constituent Assembly that would write a new constitution | ||
in 1931, she stood for a seat and was elected despite her inability to vote in the election. | ||
<h2>An advocate for women's suffrage</h2> | ||
On October of the same year, and using her position in the constituent assembly, she became the | ||
first woman to address it, in a memorable speech warning the male members of the assembly that | ||
their continued exclusion of women from voting was a violation of natural law: “To all deputies: | ||
I am a citizen before. And I reckon it would be a tremendous political mistake not to allow | ||
women to exercise this right, women that look up to and trust you; women that, similarly to the | ||
French Revolution, will undoubtedly be a new power to our laws, and you only have to open their | ||
way”. Campoamor affirmed that a Republic could not be built without half the citizenship of the | ||
country and thus, women needed to be given the right to vote. | ||
</article> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
defineOptions({ | ||
name: 'Biography', | ||
inheritAttrs: false, | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// ------------------------------------------------------------- // | ||
// This example shows how parameters can be passed to a transformer. | ||
// ------------------------------------------------------------- // | ||
|
||
function template(ast, api, options) { | ||
const optKeys = Object.keys(options) | ||
if (optKeys.length === 0) { | ||
process.stderr.write(`Pass options to this example to test its behaviour, e.g. : | ||
yarn example params --root-heading 2 | ||
This example will read \`params.rootHeading\` to exploit the value. | ||
`) | ||
} else { | ||
process.stderr.write(` | ||
Received options: | ||
${JSON.stringify(options, null, 2)} | ||
`) | ||
|
||
if (options.rootHeading) { | ||
const newTopLevel = options.rootHeading | ||
if (typeof newTopLevel !== 'number' || newTopLevel < 1 || newTopLevel > 4) { | ||
throw new Error('Invalid option --root-heading: value must be a number between 1 and 4.') | ||
} | ||
|
||
const headings = api.exploreAst( | ||
ast, | ||
({ tag, type }) => tag && tag.match(/h[1-6]/) && type === 1, | ||
) | ||
const oldTopLevel = headings | ||
.map((h) => Number(h.tag.replace('h', ''))) | ||
.reduce((min, n) => Math.min(min, n), 6) | ||
const topLevelDiff = newTopLevel - oldTopLevel | ||
|
||
headings.forEach((h) => { | ||
const currentLevel = Number(h.tag.replace('h', '')) | ||
h.tag = `h${currentLevel + topLevelDiff}` | ||
}) | ||
} | ||
} | ||
|
||
return ast | ||
} | ||
|
||
module.exports = { | ||
template, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
import type { RootNode } from '@vue/compiler-core' | ||
|
||
import * as TemplateAPI from '~/template/api' | ||
import type { Options } from '~/types/TransformationOptions' | ||
|
||
export type TemplateTransformation = (ast: RootNode, api: typeof TemplateAPI) => RootNode | ||
export type TemplateTransformation = ( | ||
ast: RootNode, | ||
api: typeof TemplateAPI, | ||
options: Options, | ||
) => RootNode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface Options { | ||
[option: string]: unknown | ||
} |