Commit Graph

28 Commits

Author SHA1 Message Date
Shubham Padia
6d93465f3b help-beta: Remove header from Zulip note.
We don't want to have a title of note and the ⓘ  icon in the note aside.
The only way to do this is to have our custom component called
ZulipNote.
2025-07-21 12:56:52 -07:00
Shubham Padia
8f51b93223 help-beta: Convert file includes that don't occupy their own lines.
The regex we were using for file includes was searching for the syntax
at the start of a line but the file includes can be followed by a `- `
as part of a list item, due to which 15 occurences of includes were not
being converted. This commit fixes that.
2025-07-21 12:56:52 -07:00
Shubham Padia
30ff98c2f6 help-beta: Function to insert flattened steps should run on includes.
We were not running this function on includes, for relative/settings
links and for nested includes, we need to flatten them in the includes
too.
2025-07-02 09:27:48 -07:00
Shubham Padia
b7fa1e6a3c help-beta: Only convert .md files.
Fixes https://chat.zulip.org/#narrow/channel/19-documentation/topic/build-help-center.20exceptions

We were getting an error during the conversion step if there was somehow
a non utf-8 file in /help. In the case that we encountered, it was most
likely .DS_Store created by MacOS.
2025-06-29 23:32:25 -07:00
Tim Abbott
ed2e9777c9 build-help-center: Don't fail the first time. 2025-06-26 11:24:31 -07:00
Shubham Padia
8d4c2b7847 help-beta: Add support for relative links.
Fixes #31253.
We've added another env variable called `SHOW_BILLING_HELP_LINKS`.
This env variable is set to `settings.CORPORATE_ENABLED` if the
`build-help-center` tool is used.
2025-06-26 10:53:53 -07:00
Shubham Padia
224b98b455 help-beta: Fix relative path during initial stages of conversion.
When we were doing it later, the issue we encountered was that when we
add support for relative links in the future, relative path fixing was
happening after `relative/help` had been added to the modified markdown
file, replacing it with `relative/help-beta` which wasn't the
replacement we intended.
2025-06-26 10:46:37 -07:00
Shubham Padia
a0deeae80e help-beta: Introduce NavigationSteps component for settings links.
Fixes #31254.
We are using `SHOW_RELATIVE_LINKS` as the env variable to set if we
want to show relative settings link or non-linked markdown instructions.
We are not trying to determine `SHOW_SETTINGS_LINK` by ourselves. See
https://chat.zulip.org/#narrow/channel/49-development-help/topic/Passing.20sitename.20for.20astro.20project.20in.20production.2E
for more details.
Until the cutover happens, we would need to manually update the mapping
in both the astro component and the python file, but since that mapping
is not frequently changed, that is a tradeoff we can make.
We had to add margin-bottom: 0 to icon styling since starlight was
inserting a margin-bottom of 1.25 em for list items.
2025-06-26 10:46:37 -07:00
Shubham Padia
1e50a98b01 help-beta: Add TODO list to keep track of items before cutover. 2025-06-23 09:48:43 -07:00
Shubham Padia
2977bf364e help-beta: Use FlattenList component instead of hacky middleware.
We want to follow the Astro way of doing things and the middleware was
adding more magic + it was violating commonmark spec:
https://spec.commonmark.org/0.31.2/#example-301.

We insert FlattenList component where include files are being
treated as part of ordered lists. Astro renders included files as it's
own component, which would result in multiple ordered lists instead of
a single list if we did not use this component. See the astro component
file itself to know more how FlattenedSteps works.

We are not inserting FlattenList component for files with !!! tip
components, since we need to do it inside the include file. There are 4
such files at the time of writing this comment.
`is_include_only_ordered_list` makes sure of that. We can do the
conversion for it manually during cutover or in a followup PR.

All unordered lists at the time of writing this comment are standalone
components and we do not need to do any transformation for them.

We also changed the order of conversion of include and main files.
Include files are now being converted first to calculate
include_files_info.

Relevant topic:
https://chat.zulip.org/#narrow/channel/19-documentation/topic/Stage.202.3A.20New.20syntax.20for.20imports
2025-06-20 16:18:16 -07:00
Shubham Padia
a80941a78d help-beta: Rename include files to use pascal case during conversion.
If the file names are in Pascal case in the first place, it will
decrease mental load for any editor to convert a kebab case name to
Pascal case name.
2025-05-30 14:53:05 -07:00
Shubham Padia
c6c7c61fee help-beta: Convert MD comments to MDX comments. 2025-05-30 14:52:15 -07:00
Shubham Padia
5bbb7ebd1a help-beta: Convert tabs syntax to equivalent MDX syntax.
Fixes #31248.
For cases with zero tabs in our current help center, we were using the
tab syntax just to put a border around the instructions without any tab
label. We do not want that border anymore since Tabs also don't have any
borders. So, we just remove the old tab syntax in that case during our
conversion.

We also move the admonition to asides conversion before the tabs syntax
conversion since the tabs conversion happening first was messing with
the asides conversion and was resulting into some missing closing tags.
We can modify things to work regardless of order, but doesn't seem worth
digging into for a conversion script.
2025-05-28 16:42:16 -07:00
Shubham Padia
a23d928662 help-beta: Indent the content inside Asides or KeyboardTip.
MDX files were getting harder to read without proper indentation.
2025-05-28 16:42:16 -07:00
Shubham Padia
078a27def2 help-beta: Convert admonitions to asides and KeyboardTip.
Fixes #31249.
We have converted `warn` to `note` since that was the translation that
remains most faithful to how we display `warn` admonitions in our
current help center implementation. See
https://chat.zulip.org/#narrow/channel/19-documentation/topic/Stage.202.3A.20New.20syntax.20for.20!!!tip.20in.20help-beta/near/2174415
for more details.

We've also duplicated code from Python-Markdown to represent how
admonitions worked there more accurately. Duplication should be fine
since this is a one-off script and Python-Markdown is not a project
that's gonna change drastically in the future.
2025-05-15 11:53:40 -07:00
Shubham Padia
dfc2a7d19a help-beta: Convert include files to mdx along with required conversion.
Earlier, we were just renaming the files in help/include and copying
them over. Which meant that none of the mdx features or any of the
components we add could be used there. We could also not support nested
imports which are a part of the help/include files.

We also set an explcit height and width of 1em for icons, since some odd
behaviour for icon height and width was noticed when writing this
commit. unplugin-icons sets height and width by itself. It was setting
the height to 1024 and 960 for some icons. It is better to set the
height explicitly.
2025-05-13 10:21:17 -07:00
Shubham Padia
b1bf937cad help-beta: Remove BASE_DIR from path.join for output_dir.
BASE_DIR is already part of output_dir. There is no need to specify it
once more.
2025-05-13 10:21:17 -07:00
Shubham Padia
130877615e help-beta: Use .insert to insert string at a particular line.
The previous logic could not handle adding the given string at the 1st
line. We also rename the function to accurately represent what it does,
insert_string_at_line.
2025-05-13 10:21:17 -07:00
Shubham Padia
bb7af6e5c1 help-beta: Refactor convert_string_to_mdx to handle file read as well.
In future, we intend to add a function that will read the include files
and do a conversion to mdx. That conversion will be different from the
conversion that we are doing right now for the main help files. That is
why we have extracted the markdown file reading logic to the
`get_markdown_string_from_file` and renamed `convert_string_to_mdx` to
`convert_help_center_file_to_mdx` to be more specific for help center
files.
2025-05-13 10:21:17 -07:00
Shubham Padia
0f85d6327d help-beta: Fix bug of not rendering font-awesome icons correctly.
In `replace_icons`, when replacing zulip icons, the original
`markdown_string` was being passed instead of the result from the
previous font-awesome icon replacement.
2025-05-13 10:21:17 -07:00
Shubham Padia
68ec074a84 help-beta: Add support for displaying zulip icons.
We're using unplugin-icons to do so.
2025-05-12 18:13:26 -07:00
Shubham Padia
c97cd1c5dd help-beta: Add support for displaying font-awesome icons.
In our app, we use the font-awesome stylesheet, add it to our webpack
bundle and use the appropriate class with the <i> tag.
Here. although for font-awesome, we can use the stylesheet to do the
same, we would need to use `webfonts-loader` for our custom icons.
In this astro project, we want to follow the Astro way, and
unplugin-icons fits better with the Astro way of doing things.
See this topic on the discussion on how we chose unplugin-icons:
https://chat.zulip.org/#narrow/channel/19-documentation/topic/Stage.202.3A.20Icons/near/2168842
2025-05-12 18:13:26 -07:00
Shubham Padia
b378e33136 help-beta: Make it easier to keep track of imports in conversion.
Before this, every function itself was responsible for adding it's own
imports. That is extra string manipulation which we had to think about
everytime we were adding new conversion function.
Now, we have an import statement set that the functions can modify, and
we have a function responsible for adding those imports. This makes it
easier in the future to add more conversion functions which might be
introducing imports.
2025-05-12 18:13:26 -07:00
Shubham Padia
b813d868a7 help-beta: Merge lists of same type adjacent to each other.
Fixes #31252.
One of our major use cases for file imports is to have bullet points as
partials to import at different places in the project. But when
importing the file with Astro, it creates its own lists. So we merge
lists together if they have nothing but whitespace between them.
There were some talks to use a component called FlattenList that would
flatten the list inside it, but that would also flatten lists that were
nested on purpose. This approach while feeling a bit hacky would not
flatten nested lists.
2025-04-15 13:55:09 -07:00
Shubham Padia
c0a2b2a31d help-beta: Convert our custom file import syntax to astro.
We use all these markdown files in `include` only to import them into
our main help markdown files. Most of these files are bulleted lists of
text. When importing these files, they might appear as an indented
sublist of an existing list. We plan to introduce mechanism to flatten
it in further commits.
2025-04-15 13:55:09 -07:00
Shubham Padia
496aa16f19 help-beta: Add component for emoticon translations table.
Fixes #31257.
2025-04-07 10:33:39 -07:00
Shubham Padia
d98446491d help-beta: Add support for images.
Partially fixes #31255. We'll need to copy images to src/ at the time of
cutover. See
https://chat.zulip.org/#narrow/stream/6-frontend/topic/Handling.20images.20in.20help.20center.20starlight.20migration.2E/near/1915130
for more details.

We've also copied over css relevant to markdown images, while making
some small changes to it so that it works better with existing
starlight styling.
2024-10-24 13:01:50 -07:00
Shubham Padia
dd9cfb5bdd tools: Add script to convert .md files to .mdx.
This is the tool that we will consistently use for our project to
migrate our help center to use starlight.
We're only doing string manipulation in this tool for now, we will
start to use existing markdown preprocessors whenever appropriate
as we start to add support for different components.
Running the tool again will overwrite the existing files.
2024-08-02 18:18:01 -07:00