Skip to content

Commit

Permalink
Fix up Showdown export, fixes #20
Browse files Browse the repository at this point in the history
  • Loading branch information
codemonkey85 committed Mar 17, 2024
1 parent 91e69cf commit 6e99d29
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
8 changes: 6 additions & 2 deletions Pkmds.Web/Components/Dialogs/ShowdownExportDialog.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<MudDialog>
@using System.Web
@using System.Text.RegularExpressions

<MudDialog>
<DialogContent>
@ShowdownExport
@((MarkupString)Regex.Replace(
HttpUtility.HtmlEncode(ShowdownExport), "\r?\n|\r", "<br />"))
</DialogContent>
<DialogActions>
<MudButton OnClick="@Close"
Expand Down
2 changes: 1 addition & 1 deletion Pkmds.Web/Components/Dialogs/ShowdownExportDialog.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public partial class ShowdownExportDialog
[CascadingParameter]
private MudDialogInstance? MudDialog { get; set; }

private string? ShowdownExport => Pokemon is not null ? AppService.ExportPokemonAsShowdown(Pokemon) : AppService.ExportPartyAsShowdown();
private string ShowdownExport => Pokemon is not null ? AppService.ExportPokemonAsShowdown(Pokemon) : AppService.ExportPartyAsShowdown();

private void Close() => MudDialog?.Close();
}
2 changes: 1 addition & 1 deletion Pkmds.Web/Components/PartyGrid.razor
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<MudButton OnClick="@ExportAsShowdown"
ButtonType="@ButtonType.Button"
Variant="@Variant.Filled"
Class=""
Class="my-3"
Color="@Color.Primary">
Export as Showdown
</MudButton>
Expand Down
2 changes: 1 addition & 1 deletion Pkmds.Web/Components/PartyGrid.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void Dispose()
}

private void ExportAsShowdown() =>
DialogService.Show<Dialogs.ShowdownExportDialog>(
DialogService.Show<ShowdownExportDialog>(
"Showdown Export",
new DialogOptions
{
Expand Down
1 change: 1 addition & 0 deletions Pkmds.Web/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
global using PKHeX.Core;
global using Pkmds.Web;
global using Pkmds.Web.Components;
global using Pkmds.Web.Components.Dialogs;
global using Pkmds.Web.Extensions;
global using Pkmds.Web.Services;
3 changes: 2 additions & 1 deletion Pkmds.Web/Services/AppService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ public string ExportPartyAsShowdown()
}

sbShowdown.AppendLine(ShowdownParsing.GetShowdownText(pkm));
sbShowdown.AppendLine();
}

return sbShowdown.ToString();
return sbShowdown.ToString().Trim();
}
}

0 comments on commit 6e99d29

Please sign in to comment.