Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------------
# To update the sha, run `docker pull node:$VERSION-alpine`
# look for something like: `Digest: sha256:0123456789abcdef`
FROM node:20-alpine@sha256:7e227295e96f5b00aa79555ae166f50610940d888fc2e321cf36304cbd17d7d6 as base
FROM node:20-alpine@sha256:ec0c413b1d84f3f7f67ec986ba885930c57b5318d2eb3abc6960ee05d4f2eb28 as base

# This directory is owned by the node user
ARG APP_HOME=/home/node/app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ You can choose from several specifications for {% data variables.actions.hosted_
| --- | ------------- | ------------- | --------------------- |
| 6 | 14 GB | 14 GB | macOS |
| 12 | 30 GB | 14 GB | macOS |
| 2 | 8 GB | 14 GB | Ubuntu |
| 2 | 8 GB | 75 GB | Ubuntu |
| 4 | 16 GB | 150 GB | Ubuntu, Windows |
| 8 | 32 GB | 300 GB | Ubuntu, Windows |
| 16 | 64 GB | 600 GB | Ubuntu, Windows |
Expand Down
80 changes: 54 additions & 26 deletions src/content-render/liquid/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,62 @@ export default {
}
return
}
text = text.trim()

// Any time what we're about to replace in here has more than one line,
// if the use of `{% data ... %}` was itself indented, from the left,
// keep *that* indentation, in replaced output, for every line.
//
// For example:
//
// 1. Bullet point
// {% data variables.foo.bar %}
//
// In this example, the `{% data ...` starts with 3 whitespaces
// (based on the `1. Bull...` in the example). So put 3 whitespaces
// in front every line of the output.
if (text.split('\n').length > 0) {
const { input, begin } = this.tagToken
let i = 1
while (input.charAt(begin - i) === ' ') {
i++ // this goes one character "to the left"
}
const goBack = input.slice(begin - i, begin)
if (goBack.charAt(0) === '\n' && goBack.length > 1) {
const numSpaces = goBack.length - 1
text = text.trim().replace(/^/gm, ' '.repeat(numSpaces)).trim()
}
} else {
text = text.trim()
}
text = handleIndent(this.tagToken, text)
text = handleBlockquote(this.tagToken, text)

return this.liquid.parseAndRender(text, scope.environments)
},
}

function handleIndent(tagToken, text) {
// Any time what we're about to replace in here has more than one line,
// if the use of `{% data ... %}` was itself indented, from the left,
// keep *that* indentation, in replaced output, for every line.
//
// For example:
//
// 1. Bullet point
// {% data variables.foo.bar %}
//
// In this example, the `{% data ...` starts with 3 whitespaces
// (based on the `1. Bull...` in the example). So put 3 whitespaces
// in front every line of the output.
if (text.split('\n').length === 0) return text
const { input, begin } = tagToken
let i = 1
while (input.charAt(begin - i) === ' ') {
i++ // this goes one character "to the left"
}
const goBack = input.slice(begin - i, begin)
if (goBack.charAt(0) === '\n' && goBack.length > 1) {
const numSpaces = goBack.length - 1
return text.replace(/^/gm, ' '.repeat(numSpaces)).trim()
}
return text
}

// When a reusable has multiple lines, and the input line is a blockquote,
// keep the blockquote character on every successive line.
const blockquoteRegexp = /^\n?([ \t]*>[ \t]?)/
function handleBlockquote(tagToken, text) {
// If the text isn't multiline, skip
if (text.split('\n').length <= 1) return text

// If the line with the liquid tag starts with a blockquote...
const { input, content } = tagToken
const inputLine = input.split('\n').find((line) => line.includes(content))
if (!blockquoteRegexp.test(inputLine)) return text

// Keep the character on successive lines
const start = inputLine.match(blockquoteRegexp)[0]
return text
.split('\n')
.map((line, i) => {
if (i === 0) return line
if (blockquoteRegexp.test(line)) return line
return start + line.trim()
})
.join('\n')
}