profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/paulstatezny/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Paul Statezny paulstatezny @ucbi Phoenix, AZ https://paulstat.com I'm a software developer specializing in full-stack web development.

paulstatezny/elm-local-storage-ports 17

Generic Elm ports for interacting with LocalStorage

paulstatezny/decisive 9

The elegant, free Eisenhower Matrix app

paulstatezny/elm-phoenix-websocket-ports 8

Generic Elm ports for interacting with the Phoenix framework via websocket

paulstatezny/elm-dom-ports 5

Generic Elm ports for interacting with the DOM

paulstatezny/live-view-back-button 2

Testing out using the back button with Phoenix LiveView

paulstatezny/angular-decisive 1

The elegant, free Eisenhower Matrix app

paulstatezny/angular-dry-scope 1

Bringing functional UI paradigms to Angular 1.

paulstatezny/elm-router 1

Create a website with many small Elm applications, powered by reusable Elm ports from NPM.

mattludwigs/lunch-and-learn-reason-todo 0

Practice app to learn ReasonML and ReasonReact with a lunch crew

paulstatezny/advent-of-code-2017 0

Solutions to exercises from http://adventofcode.com/2017

issue commenttlux/sftp_client

Upgrading to OTP 24 - returning "Key exchange failed" error on connecting.

Thank you!!! It would be so wonderful if this were emphasized in the docs. Took me a while to arrive here. 😅

wkirschbaum

comment created time in 4 days

pull request commentelixir-lang/elixir

Formatter plugins

On behalf of the entire Surface community, a big thank you! This is going to scratch a common itch. 🙂

josevalim

comment created time in 14 days

issue closedsurface-ui/surface_formatter

Unnecessarily indents css classes on each run

Bug can be reproduced on this sample repo https://github.com/anildigital/surface_formatter_bug

$ mix surface.format

<TextInput
  class={
    "w-full h-12 max-w-full px-4 bg-xxx-100 hover:bg-xxx-120 text-base leading-normal
     text-color-yyy-100 box-border border border-solid border-kkk-100 rounded transition
     ease-in placeholder-hhh-100 placeholder-opacity-100 disabled:opacity-50
     disabled:cursor-not-allowed focus:border-mmmm-100 focus:outline-none
     no-scrollbar invalid:shadow-none invalid:border-ttt-100 #{@class}",

Then run again

$ mix surface.format

<TextInput
  class={
    "w-full h-12 max-w-full px-4 bg-xxx-100 hover:bg-xxx-120 text-base leading-normal
          text-color-yyy-100 box-border border border-solid border-kkk-100 rounded transition
          ease-in placeholder-hhh-100 placeholder-opacity-100 disabled:opacity-50
          disabled:cursor-not-allowed focus:border-mmmm-100 focus:outline-none
          no-scrollbar invalid:shadow-none invalid:border-ttt-100 #{@class}",

then run again

$ mix surface.format

<TextInput
  class={
    "w-full h-12 max-w-full px-4 bg-xxx-100 hover:bg-xxx-120 text-base leading-normal
                text-color-yyy-100 box-border border border-solid border-kkk-100 rounded transition
                ease-in placeholder-trunks-100 placeholder-opacity-100 disabled:opacity-50
                disabled:cursor-not-allowed focus:border-mmmm-100 focus:outline-none
                no-scrollbar invalid:shadow-none invalid:border-ttt-100 #{@class}",

closed time in a month

anildigital

issue commentsurface-ui/surface_formatter

Unnecessarily indents css classes on each run

@anildigital Yes, this is expected. I've added a new section that explains how this affects string attributes/props:


https://hexdocs.pm/surface_formatter/0.5.4/Surface.Formatter.html#format_string!/2-whitespace-in-string-attributes

Code semantics must be maintained

It's critical that a code formatter never change the semantics of the code it modifies. In other words, the behavior of a program should never change due to a code formatter.

The Whitespace section above outlines how SurfaceFormatter preserves code semantics by refusing to modify contents of <script>, <code> and <pre> tags as well as macro components. And for the same reason, the formatter does not introduce whitespace between HTML tags when there is none.

Code semantics in string attributes

SurfaceFormatter cannot reliably guess whether application behavior will be changed by formatting the contents of a string. For example, consider a component with the following interface:

<List items="
apples (fuji)
oranges (navel)
bell peppers (green)
" />

The component internally splits on newline characters and outputs the following HTML:

<ul>
  <li>apples (fuji)</li>
  <li>oranges (navel)</li>
  <li>bell peppers (green)</li>
</ul>

If SurfaceFormatter assumes it is safe to modify whitespace in string attributes, then the Surface code would likely change to this:

<List items="apples (fuji) oranges (navel) bell peppers (green)" />

Which would output the following HTML:

<ul>
  <li>apples (fuji) oranges (navel) bell peppers (green)</li>
</ul>

Notice that the behavior of the application would have changed simply by running the formatter. It is for this reason that SurfaceFormatter always retains precisely the same whitespace in attribute strings, including both space and newline characters.


Some might feel this is a rare case that should be ignored, or that attributes/props named class should be treated differently. And if there's enough support perhaps we should consider ways to customize this behavior. However, until there's a clear reason to change I've been intentionally conservative.

anildigital

comment created time in a month

delete branch surface-ui/surface_formatter

delete branch : document-string-attribute-whitespace-retention

delete time in a month

push eventsurface-ui/surface_formatter

Paul Statezny

commit sha 38b0a1e77add39c9ede017b7a6ca615fa13099f4

Update docs with new syntax and explain why whitespace is retained in string attributes

view details

Paul Statezny

commit sha 1ad372b561421f810f0e743e4383e6731183f1f5

Increase header size and correct ~H to ~F

view details

Paul Statezny

commit sha ddc63a552185a6cd668d5c7d6fdd5ffd2b1857a1

Merge pull request #44 from surface-ui/document-string-attribute-whitespace-retention Document string attribute whitespace retention

view details

push time in a month

push eventsurface-ui/surface_formatter

Paul Statezny

commit sha 1ad372b561421f810f0e743e4383e6731183f1f5

Increase header size and correct ~H to ~F

view details

push time in a month

issue commentsurface-ui/surface_formatter

Unnecessarily indents css classes on each run

@anildigital I cloned https://github.com/anildigital/surface_formatter_bug, bumped to v0.5.4, and it's not modifying lib/surface_formatter_bug_web/live/text_input_new.ex.

$ mix surface.format lib/surface_formatter_bug_web/live/text_input_new.ex
$ git status
                                                                09:36:02
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	modified:   mix.exs
	modified:   mix.lock

Is it possible the tab characters are from your editor? The formatter doesn't introduce tab characters and never has, so I don't see how it's possible those are coming from it.

anildigital

comment created time in a month

issue commentsurface-ui/surface_formatter

Unnecessarily indents css classes on each run

Now we are fully in the Twilight Zone. 😂

I'll take a look. Thanks @anildigital.

anildigital

comment created time in a month

issue commentsurface-ui/surface_formatter

Unnecessarily indents css classes on each run

@anildigital Thanks for your patience. I did some refactoring to clean up some tech debt to make isolating and exploring the problem easier. It should be fixed now in v0.5.4 (third time's a charm!), but can you post back to confirm or deny from your end?

Thanks for going back and forth with me!

anildigital

comment created time in a month

IssuesEvent

created tagsurface-ui/surface_formatter

tagv0.5.4

created time in a month

push eventsurface-ui/surface_formatter

Paul Statezny

commit sha ee560dbc913f9edd362b55fac9c589f116fe42b4

v0.5.4

view details

push time in a month

delete branch surface-ui/surface_formatter

delete branch : 36-interpolation-in-expression-attribute-multiline-indentation

delete time in a month

delete branch surface-ui/surface_formatter

delete branch : 36-expression-attribute-indentation

delete time in a month

push eventsurface-ui/surface_formatter

Paul Statezny

commit sha 0a998514de1ad30389ad5d7d0a0fe8f95e495a5f

#36: Fix bug in expression attributes with strings containing newlines in indented nodes

view details

Paul Statezny

commit sha e66bf9976dd59884735ea19a3267034149d61ced

Merge pull request #43 from surface-ui/36-expression-attribute-indentation Fix indentation for expression attributes with strings containing newlines in indented nodes

view details

push time in a month

Pull request review commentsurface-ui/surface_formatter

Fix indentation for expression attributes with strings containing newlines in indented nodes

 defmodule Surface.FormatterTest do    test "Multi-line strings in lists in attributes aren't indented every time the formatter is ran" do     assert_formatter_doesnt_change(~S"""-    <First-      class={-        "w-full h-12 max-w-full px-4 bg-black-100 hover:bg-black-120 text-base leading-normal-         text-color-bulma-100 box-border border border-solid border-yellow-100 rounded transition-         ease-in placeholder-cyan-100 placeholder-opacity-100 disabled:opacity-50-         disabled:cursor-not-allowed focus:border-red-100 focus:outline-none-         no-scrollbar invalid:shadow-none invalid:border-green-100 #{@class}",-        "pl-11": @left_icon,-        "pr-11": @right_icon,-        "border-green-100": @error-      }-      field={@field}-      opts={[-        placeholder: @placeholder,-        disabled: @disabled,-        required: @required-      ]}-      value={@value}-      focus={@on_focus}-      blur={@on_blur}-    />+    <Wrapper>+      <Wrapper>+        <First

Indenting the component allowed the test to reproduce the bug.

paulstatezny

comment created time in a month

PullRequestReviewEvent

delete branch surface-ui/surface_formatter

delete branch : refactor-render

delete time in a month

push eventsurface-ui/surface_formatter

Paul Statezny

commit sha 282142829058ce52b2d47a05d49422096a46f1c8

Clean up some tech debt in Render phase

view details

Paul Statezny

commit sha 0b5020883d9052cf365e028faadbba82a1627c53

Extract render_opening_tag

view details

Paul Statezny

commit sha cd71e9d3a01156f734bfe3b0681330ece682e9d1

Fix typo

view details

Paul Statezny

commit sha bef3a9c5158b612b5ada0f65e7d34a6c557f486a

Run formatter

view details

Paul Statezny

commit sha a66ad9a93ae7b87b8df27933b9b08e680404e613

Merge pull request #42 from surface-ui/refactor-render Refactor Render phase

view details

push time in a month

PR merged surface-ui/surface_formatter

Refactor Render phase

Adds extra indirection as an attempt to make the code more approachable and easier to reason about.

+218 -227

0 comment

2 changed files

paulstatezny

pr closed time in a month

push eventsurface-ui/surface_formatter

Paul Statezny

commit sha 282142829058ce52b2d47a05d49422096a46f1c8

Clean up some tech debt in Render phase

view details

Paul Statezny

commit sha 0b5020883d9052cf365e028faadbba82a1627c53

Extract render_opening_tag

view details

Paul Statezny

commit sha cd71e9d3a01156f734bfe3b0681330ece682e9d1

Fix typo

view details

Paul Statezny

commit sha bef3a9c5158b612b5ada0f65e7d34a6c557f486a

Run formatter

view details

push time in a month

PR opened surface-ui/surface_formatter

Refactor Render phase

Adds extra indirection as an attempt to make the code more approachable and easier to reason about.

+218 -227

0 comment

2 changed files

pr created time in a month